Last active
April 9, 2019 23:46
-
-
Save macloo/57ae5591211205745986442f422fa109 to your computer and use it in GitHub Desktop.
Run Chrome headless with Selenium
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
import time | |
from selenium import webdriver | |
from selenium.webdriver.chrome.options import Options | |
from bs4 import BeautifulSoup | |
chrome_options = Options() | |
chrome_options.add_argument("--headless") | |
# fill in your own path to installed chromedriver | |
driver = webdriver.Chrome(executable_path='/Users/dirname/dirname/dirname//chromedriver', | |
options=chrome_options) | |
# fill in URL for page you want to scrape | |
driver.get('https://somedomain.com'); | |
time.sleep(2) | |
html = driver.page_source | |
soup = BeautifulSoup(html, "html.parser") | |
h1_list = soup.find_all('h1') | |
print(h1_list) | |
driver.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Getting started with Selenium
http://bit.ly/selenium-intro