Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Screen Scraping a Javascript based webpage in Python

I am working on a screen scraping tool in Python. But, as I look through the source of the webpage, I noticed that most of the data is coming through Javascript.

Any idea, how to scrape javascript based webpage ? Any tool in Python ?

Thanks

like image 268
Kiran Avatar asked Dec 17 '22 07:12

Kiran


2 Answers

Scraping javascript-based webpages is possible with selenium. In particular, try the Selenium WebDriver.

like image 177
unutbu Avatar answered Dec 31 '22 12:12

unutbu


I use webkit, which is the browser renderer behind Chrome and Safari. There are Python bindings to webkit through Qt.

And here is a full Python example to execute JavaScript and extract the final HTML.

like image 24
hoju Avatar answered Dec 31 '22 14:12

hoju