Last active
December 27, 2018 05:19
-
-
Save py-ranoid/e53ad0bb3dfdaa96dff7dbd7f0764b0f to your computer and use it in GitHub Desktop.
Fetching a website's source (HTML) with Selenium over Python.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver,common | |
""" | |
How to Download Chrome Driver : | |
- Go to https://chromedriver.storage.googleapis.com/index.html?path=2.45/ | |
- Download and unzip webdriver for your OS | |
- Move the webdriver to a where it can be accessed by python. (Same directory or $PATH) | |
""" | |
try : | |
browser = webdriver.Chrome() | |
except common.exceptions.WebDriverException as e: | |
print ("Download Chrome Webdriver\n"+e.message) | |
exit() | |
def get_page_html(url="www.github.com"): | |
browser.get(url) | |
return browser.page_source | |
if __name__ == "__main__": | |
print (get_page_html()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment