我正在尝试查看是否在YouTube视频上启用了评论部分。如果不是,程序应该再次返回顶部。
def bot1():
while True:
# First search
driver.get("https://www.youtube.com/results?sp=CAISAggBUBQ%253D&q=" + k1)
driver.find_element_by_class_name("yt-uix-tile-link").click()
try:
WebDriverWait(driver, 15).until(
EC.presence_of_element_located((By.CLASS_NAME, "comment-simplebox-renderer-collapsed-content"))
)
except TimeoutException:
bot1()
这给了我错误
Traceback (most recent call last):
File "C:/Users/Admin/Desktop/My Programs/YouTubeTest/YouTubeTest.py", line 98, in <module>
bot1()
File "C:/Users/Admin/Desktop/My Programs/YouTubeTest/YouTubeTest.py", line 73, in bot1
EC.presence_of_element_located((By.CLASS_NAME, "comment-simplebox-renderer-collapsed-content"))
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\support\wait.py", line 80, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
我有这个
from selenium.common.exceptions import TimeoutException
我完全不知道为什么会这样。