Introduction
In this post, I’m using selenium
to demonstrate how to web scrape a JavaScript enabled page.
Why not Beautiful Soup ?
If you had some experience of using python for web scraping, you probably already heard of beautifulsoup
and urllib
. By using the following code, we will be able to see the HTML and then use HTML tags
to extract the desired elements. However, if the web page embedded with JavaScript, you will notice that some of the HTML elements can’t be seen from the beautiful soup, because they are rendered by the JavaScript. Instead you will only see the script
tags, which indicate the place where the JavaScript codes are placed.