我正在使用 selenium-wire 使用 Chrome 浏览器单击按钮。直到今天,我的代码运行良好。但是,现在我收到以下错误,我不知道为什么:
Traceback (most recent call last):
File "Scraping_fx.py", line 1, in <module>
from seleniumwire import webdriver
File "C:\Users\me\Anaconda3\envs\project\lib\site-
packages\seleniumwire\webdriver\__init__.py", line 3, in <module>
from .browser import Chrome, Edge, Firefox, Safari # noqa
File "C:\Users\me\Anaconda3\envs\project\lib\site-
packages\seleniumwire\webdriver\browser.py", line 14
def __init__(self, *args, seleniumwire_options=None, **kwargs):
^
SyntaxError: invalid syntax
我正在使用 python 2.7.16;硒线 1.0.4。
from seleniumwire import webdriver
from selenium.common.exceptions import ElementClickInterceptedException,NoSuchElementException
import logging
def scrape_website(url):
# Configure browser driver
options = webdriver.ChromeOptions()
options.add_argument('--no-sandbox')
options.add_argument('--disable-gpu')
options.add_argument('--headless')
#Instantiate driver and navigate to URL
driver = webdriver.Chrome(chrome_options=options)
driver.implicitly_wait(30)
driver.get(url)
我在这里错过了什么吗?