import requests import selenium import wheel from selenium import webdriver from selenium.webdriver.firefox.options import Options as FOptions from selenium.webdriver.chrome.options import Options as COptions # driver = webdriver.Chrome(executable_path="D:PDFpy包chromedriver_win32chromedriver.exe") # driver1 = webdriver.Firefox(executable_path="D:PDFpy包geckodriver_win64geckodriver.exe") # Selenium support for PhantomJS has been deprecated, please use headless versions of Chrome or Firefox instead # 分手了 可以采用浏览器无头模式 红字是我容易忘记的地方 会导致报错 driver去官网下载即可 # browser = webdriver.PhantomJS(executable_path="D:PDFpy包phantomjsphantomjs.exe") # browser.get("www.baidu.com") """ 无头模式 """ options = COptions() options.add_argument('-headless') driver = webdriver.Chrome(executable_path="D:PDFpy包chromedriver_win32chromedriver.exe", chrome_options=options) driver.get("http://www.sina.com") print(driver.current_url)