selenium+chromeheadless爬取网站
chromedriver
selenium
chrome --headless无头模式
phantomjs
from selenium import webdriver
options = webdriver.ChromeOptions()
#options.binary_location = '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'
options.add_argument('window-size=800x841')
#options.add_argument('headless')
driver = webdriver.Chrome(chrome_options=options)
driver.get('https://www.baidu.com')
topLinks = driver.find_elements_by_xpath("//div/p/a[contains(@class, 'title')]")
for link in topLinks:
print 'Title: ', link.text
driver.quit()