通常 TimeoutException(消息,屏幕,堆栈跟踪)发生。
但很少抓取脚本从网站获取准确的数据。
这是我编写的代码段。
Netbet = webdriver.Chrome(executable_path=os.path.abspath("/usr/bin/chromedriver"))
Netbet.get("https://www.livepartners.com/")
Netbet.implicitly_wait(10)
Netbet.find_element_by_id("login_username").send_keys("username")
Netbet.find_element_by_id("login_password").send_keys("password")
pwd = Netbet.find_element_by_id("login_password")
pwd.send_keys(Keys.RETURN)
waiter = wait(Netbet, 10)
waiter.until(EC.visibility_of_element_located((By.XPATH, '//*[@id="contentwrapper"]/div/div[1]/div[2]/div')))
balance = Netbet.find_element_by_xpath('//*[@id="contentwrapper"]/div/div[1]/div[2]/div/strong').text
使用此脚本,我可以抓取确切数据很少,但通常获取TimeoutException(message, screen, stacktrace)
错误。
Traceback (most recent call last):
File "netbet.py", line 43, in <module>
data = netbet_scrapping()
File "netbet.py", line 31, in netbet_scrapping
waiter.until(EC.visibility_of_element_located((By.XPATH, '//*[@id="contentwrapper"]/div/div[1]/div[2]/div')))
File "/home/elite/.local/lib/python3.5/site-packages/selenium/webdriver/support/wait.py", line 80, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
我不确定为什么会这样。