How to get page source in Selenium?

You can easily get the page source in Selenium via the page_source attribute of the Selenium web driver.

Here is some sample code for getting the page source of the ScrapingBee website:

from selenium import webdriver

DRIVER_PATH = '/path/to/chromedriver'
driver = webdriver.Chrome(executable_path=DRIVER_PATH)

driver.get("http://www.scrapingbee.com")

# Print page source on screen
print(driver.page_source)

Related Selenium web scraping questions: