该脚本应该打开浏览器,登录到网站,转到网站中的页面,然后在不同的类标记中查找更改。我现在的问题是它无法从我想要的标签中拉出,而且我意识到它并没有连续运行,这意味着一旦发现更改,该脚本就会关闭,我希望它重新启动以继续寻找变化。
我尝试了多种方法使其正常运行,但似乎都没有。我得出的结论是我写错了,不知道该怎么办。
import time
import requests
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
import ssl
from twilio.rest import Client
from twilio.rest import TwilioRestClient
email = '*****'
password = '*****'
browser = webdriver.Chrome()
browser.get(('http://hubzu.com'))
time.sleep(8)
loginButton = browser.find_element_by_id('loginNewPopup')
loginButton.click()
time.sleep(3)
emailform = browser.find_element_by_id('loginEmailAddress')
emailform.send_keys(email)
passform = browser.find_element_by_id('loginPassword')
passform.send_keys(password)
time.sleep(3)
signInButton = browser.find_element_by_id('gobalSignInSubmit')
signInButton.click()
time.sleep(5)
print('>>> We have logged in using ' +email+', ' +password)
browser.get(('https://www.hubzu.com/property/0007131273067-702-Nw-126th-Ct-Miami-FL-33182'))# Live Auction Bid URL
time.sleep(2)
try: #EVERYTHING ABOVE WORKS SMOOTHLY
WebDriverWait(browser, 10).until( # HERE IS WHERE THE PROBLEM IS
EC.text_to_be_present_in_element((By.CLASS, 'bid-time bid-secs'), r"((?<=\()[0-9]*)")
)
finally:
from twilio.rest import Client
# Your Account SID from twilio.com/console
account_sid = "*****"
# Your Auth Token from twilio.com/console
auth_token = "******"
client = Client(account_sid, auth_token)
message = client.messages.create(
to="******",
from_="******",
body='Test')
错误:
Traceback (most recent call last):
File "2_1.py", line 55, in <module>
EC.text_to_be_present_in_element((By.CLASS_NAME, 'bid-time bid-secs'), r"((?
<=\()[0-9]*)")
File "C:\Program Files (x86)\Python37-32\lib\site-
packages\selenium\webdriver\support\wait.py", line 80, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: