我试图创建一个功能,爬网整个网站。 今天有个TimeoutException。。。你知道吗
Traceback (most recent call last):
File "D:/Entwicklung/example/crawler/crawler.py", line 46, in crawl
driver.get(tmp)
File "C:\Users\test\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get
self.execute(Command.GET, {'url': url})
File "C:\Users\test\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\test\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: timeout
(Session info: chrome=75.0.3770.142)
TimeoutException是当我将视频的url传递给驱动程序。获取()功能。 我的循环运行,但每驱动程序。获取()TimeoutException之后的调用也会激发TimeoutException。为什么会这样?你知道吗
while len(diff) > 0:
tmp = diff.pop()
visited.add(tmp)
driver.get(tmp)
elements = driver.find_elements_by_tag_name("a")
for element in elements:
href = element.get_attribute('href')
if href is None:
continue
else:
if main_url in href:
links.add(href)
diff = links.difference(visited)
您的代码正在达到此默认超时,这就是您看到此消息的原因。你知道吗
你试过用Waits吗?在进入下一个代码块之前,它们会给Selenium多一点时间。你知道吗
找到另一个博客:Dealing with Selenium timeouts。他们修改了Selenium的默认超时设置。你知道吗
相关问题 更多 >
编程相关推荐