最近在阅读爬虫教程 莫烦-爬虫教程,其中提到了selenium包,但怎么在windows系统上调用浏览器driver呢?
from selenium import webdriver
browser = webdriver.Chrome()
会报错'chromedriver' executable needs to be in PATH.
在尝试了把driver.exe放在path中等方法后,找到一个解决方法【解决方法】
chromedriver_loc = '/path/to/chromedriver' driver = webdriver.Chrome(executable_path=chromedriver_loc)
那么怎么让网页不弹出呢 【不弹出网页】
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument("headless")
self.driver = webdriver.Chrome(executable_path='/Users/${userName}/Drivers/chromedriver', chrome_options=options)