Selenium is a Python module for browser automation. You can use it to grab html code, what webpages are made of: HyperText Markup Language (HTML).

To get it, first start the web browser and load the page. Then you can fetch it. For this to work, a web driver must be installed.

Related course:

get html

selenium get html

The code below starts the Firefox web rbowser, opens a webpage with the get() method and finally stores the webpage html with browser.page_source.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#_*_coding: utf-8_*_

from selenium import webdriver
import time

# start web browser
browser=webdriver.Firefox()

# get source code
browser.get("https://en.wikipedia.org")
html = browser.page_source
time.sleep(2)
print(html)

# close web browser
browser.close()

selenium get html

Download examples