**********<Example Code>*********************
from selenium import webdriver
link = ["https://www.naver.com", "https://www.google.com", "https://13.59.54.26:443", "https://www.daum.net"]
for i in link:
driver = webdriver.Chrome("C:/chrome/chromedriver.exe")
driver.get(i)
driver.quit()
**********<Question>*****************************************
I want to access any page using Cellinium through a repeat statement, but when I access to a non-existent page address such as
Is there a way to ignore the error message that occurs even when accessing a page that does not exist, and lead to the next search result?
**********<Error Message>***********************
ebDriverException Traceback (most recent call last)Input In [30], in () 59 for i in link: 60 driver = webdriver.Chrome("C:/chrome/chromedriver.exe")---> 61 driver.get(i) 62 driver.quit()File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py:447, in WebDriver.get(self, url) 443 def get(self, url: str) -> None: 444 """ 445 Loads a web page in the current browser session. 446 """--> 447 self.execute(Command.GET, {'url': url})File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py:435, in WebDriver.execute(self, driver_command, params) 433 response = self.command_executor.execute(driver_command, params) 434 if response:--> 435 self.error_handler.check_response(response) 436 response['value'] = self._unwrap_value( 437 response.get('value', None)) 438 return responseFile ~\AppData\Local\Programs\Python\Python310\lib\site-packages\selenium\webdriver\remote\errorhandler.py:247, in ErrorHandler.check_response(self, response) 245 alert_text = value['alert'].get('text') 246 raise exception_class(message, screen, stacktrace, alert_text) # type: ignore[call-arg] # mypy is not smart enough here--> 247 raise exception_class(message, screen, stacktrace)WebDriverException: Message: unknown error: net::ERR_CONNECTION_TIMED_OUT (Session info: chrome=103.0.5060.66)Stacktrace:Backtrace: Ordinal0 [0x009A6463+2188387] Ordinal0 [0x0093E461+1762401] Ordinal0 [0x00853D78+802168] Ordinal0 [0x008504E8+787688] Ordinal0 [0x0084654D+746829] Ordinal0 [0x0084710A+749834] Ordinal0 [0x0084675A+747354] Ordinal0 [0x00845D3F+744767] Ordinal0 [0x00844C28+740392] Ordinal0 [0x008450FD+741629] Ordinal0 [0x00855544+808260] Ordinal0 [0x008AD2DD+1168093] Ordinal0 [0x0089C7DC+1099740] Ordinal0 [0x008ACC22+1166370] Ordinal0 [0x0089C5F6+1099254] Ordinal0 [0x00876BE0+945120] Ordinal0 [0x00877AD6+948950] GetHandleVerifier [0x00C471F2+2712546] GetHandleVerifier [0x00C3886D+2652765] GetHandleVerifier [0x00A3002A+520730] GetHandleVerifier [0x00A2EE06+516086] Ordinal0 [0x0094468B+1787531] Ordinal0 [0x00948E88+1805960] Ordinal0 [0x00948F75+1806197] Ordinal0 [0x00951DF1+1842673] BaseThreadInitThunk [0x7609FA29+25] RtlGetAppContainerNamedObjectPath [0x770F7A9E+286] RtlGetAppContainerNamedObjectPath [0x770F7A6E+238]
python selenium crawling
from selenium import webdriver
link = ["https://www.naver.com", "https://www.google.com", "https://13.59.54.26:443", "https://www.daum.net"]
for i in link:
try:
driver = webdriver.Chrome("C:/chrome/chromedriver.exe")
driver.get(i)
driver.quit()
except:
continue
Can we do this?
© 2024 OneMinuteCode. All rights reserved.