from selenium import webdriver browser = webdriver.Firefox() browser.get("http://example.com") html_source = browser.page_source if "whatever" in html_source: # do something else: # do something else