from selenium.webdriver.chrome.options import Options
options = Options()
options.add_argument("--proxy-server=127.0.0.1:8118")
s = Service(r'C:/Program Files/Mozilla Firefox/geckodriver.exe')
driver = webdriver.Firefox(service=s,options=options)
url = 'https://item.taobao.com'
driver.get(url)
运行时出错
AttributeError:‘Options’ object has no attribute ‘binary’
最后发现是import时候出错了 chrome改成firefox就好了
正确代码:
from selenium.webdriver.firefox.options import Options
options = Options()
options.add_argument("--proxy-server=127.0.0.1:8118")
s = Service(r'C:/Program Files/Mozilla Firefox/geckodriver.exe')
driver = webdriver.Firefox(service=s,options=options)
url = 'https://item.taobao.com'
driver.get(url)