我正在将 python selenium-webdriver 用于网络抓取项目。问题是在 driver.get() 将我重定向到“重定向你太多次”页面后,我收到了这个错误
Traceback (most recent call last):
File "C:\Users\t\Desktop\New folder\stript.py", line 177, in <module>
main()
File "C:\Users\t\Desktop\New folder\script.py", line 135, in main
driver.get(k)
File "C:\Users\t\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get
self.execute(Command.GET, {'url': url})
File "C:\Users\t\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\t\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Reached error page: about:neterror?e=redirectLoop&u=https%3A//www.libris.ro/drept-procesual-civil-vol-2-procedura-SOL978-606-94050-7-9--p1192365.html&c=UTF-8&d=Firefox%20has%20detected%20that%20the%20server%20is%20redirecting%20the%20request%20for%20this%20address%20in%20a%20way%20that%20will%20never%20complete.
我试图处理这样的异常
try:
driver.get(url + '?pgn=100&pg=' + str(i))
except WebDriverException:
i += 1
continue
但它不起作用。有没有可能处理这个异常?