how to get webpage window data with python?

Viewed 650

I am looking for a way to access a website's window varibles through python how can I do this?

For example, I want to get the data from window.performance. How can I do that with python? Is it possible to use the requests library?

I have attached the image: I have attached the image

2 Answers

Python requests doesn't have access to running JavaScript on the page, which is what you'll need to get metrics like that. Requests will only gather the raw HTML data (what you see when you view the page source), and it won't be able to gather the JavaScript window object.

To do such a thing like this, you'll need a headless browser, which has access to inline JavaScript on the website. Something like this might interest you.

Regardless, you should look into using a headless browser which would have access to the live rendered site. Something like Selenium, Nightmare, Puppeteer, etc. would be of good use in this instance.


the case is retrieving data which web app stores in the window js object or global scope in browser. The workflow is programming or instructing a headless browser with corresponding API in your language. #programming##data retrieve##access the window object in browser#

Related