inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

현존 최강 크롤링 기술: Scrapy와 Selenium 정복

크롬드라이버 작동 후 꺼짐

해결된 질문

1866

hobul

작성한 질문수 3

0

셀레니움 모듈 설치 후 윈도우 c드라이버(C:/dev_python/Webdriver/chromedriver) 폴더에

크롬드라이버까지는 설치를 했고 아래 소스코드를 실행시키면 크롬 창이 열리긴 합니다. 

==============================================

from selenium import webdriver

from selenium.webdriver.common.keys import Keys

chromedriver = 'C:/dev_python/Webdriver/chromedriver'

driver = webdriver.Chrome(chromedriver)

==============================================

문제는 열린 후에 저절로 종료가 되며 아래와 같은 에러 메시지가 뜨는데요..

---------------------------------------------------------------------------
WebDriverException                        Traceback (most recent call last)
<ipython-input-22-3fda3c2e7dab> in <module>
      3 
      4 chromedriver = 'C:/dev_python/Webdriver/chromedriver'
----> 5 driver = webdriver.Chrome(chromedriver)

~\anaconda3\lib\site-packages\selenium\webdriver\chrome\webdriver.py in __init__(self, executable_path, port, options, service_args, desired_capabilities, service_log_path, chrome_options, keep_alive)
     74 
     75         try:
---> 76             RemoteWebDriver.__init__(
     77                 self,
     78                 command_executor=ChromeRemoteConnection(

~\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py in __init__(self, command_executor, desired_capabilities, browser_profile, proxy, keep_alive, file_detector, options)
    155             warnings.warn("Please use FirefoxOptions to set browser profile",
    156                           DeprecationWarning, stacklevel=2)
--> 157         self.start_session(capabilities, browser_profile)
    158         self._switch_to = SwitchTo(self)
    159         self._mobile = Mobile(self)

~\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py in start_session(self, capabilities, browser_profile)
    250         parameters = {"capabilities": w3c_caps,
    251                       "desiredCapabilities": capabilities}
--> 252         response = self.execute(Command.NEW_SESSION, parameters)
    253         if 'sessionId' not in response:
    254             response = response['value']

~\anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py in execute(self, driver_command, params)
    319         response = self.command_executor.execute(driver_command, params)
    320         if response:
--> 321             self.error_handler.check_response(response)
    322             response['value'] = self._unwrap_value(
    323                 response.get('value', None))

~\anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py in check_response(self, response)
    240                 alert_text = value['alert'].get('text')
    241             raise exception_class(message, screen, stacktrace, alert_text)
--> 242         raise exception_class(message, screen, stacktrace)
    243 
    244     def _value_or_default(self, obj, key, default):

WebDriverException: Message: unknown error: unable to discover open pages
  (Driver info: chromedriver=2.0,platform=Windows NT 6.2 x86_64)

에러의 원인이 무엇일까요?

scrapy 웹-크롤링 selenium

답변 2

1

잔재미코딩 DaveLee

안녕하세요. 특이한 에러이긴 하네요. 저도 저런 에러를 유추하기는 어려운데요.

우선 chrome 버전도 최신으로 업데이트해보시고,

chromedriver도 해당 버전에 맞춰서 새로 다운로드받아보시면 어떨까 하고요.

다음으로 마지막 에러메세지를 검색해본 결과 다음과 같은 옵션을 써보시는 것도 좋을 것 같습니다.

https://stackoverflow.com/questions/52208663/selenium-common-exceptions-webdriverexception-message-unknown-error-unable-to

-----------------

Add the argument --no-sandbox through ChromeOptions() to your existing code as follows:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

options = Options()
options.add_argument('--no-sandbox') # Bypass OS security model
driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:\path\to\chromedriver.exe')
driver.get('http://www.python.org')
print(driver.title)
driver.quit()

0

hobul

크롬브라우저가 최신으로 업데이트가 안되어 있었습니다. 

최신 브라우저 버전과 맞는 크롬드라이버 설치후 코딩 실행하니 무사히 작동되었습니다..^^;

답변 감사합니다.  (_ . _)

파이썬 기초편 완강 후 크롤링 심화편과 MySQL 강좌 듣고 있습니다. 

좋은 강의 준비하시느라 고생하십니다. 잘 따라 가겠습니다.~

코딩을 잘 따라 한 것 같은데 오류가 발생하는 것 같습니다

0

622

1

scrapy를 jupyter 환경에서 할 수 있나요

0

357

1

[실전 크롤링: scrapy 크롤링 팁] 질문있습니다.

0

309

1

[실전 크롤링: 지마켓 크롤링하며, scrapy 실전 활용법 익히기1] 5분50초쯤 질문

0

218

1

[강력/최신 크롤링 기술: Scrapy 로 지마켓 크롤링하기1] 관련 질문

0

276

1

xml을 parsing할때 <을 &lt; 로 인식합니다.

0

332

1

pipelines.py에서 process_item내에서 print문이 작동을 하지 않네요 ㅠ

0

289

3

PhantomJS 문의

0

292

1

selenium 문의

0

326

1

브라우저 제어해서 크롤링하기 - 처음강의 마지막부분 문의

0

3002

1

on error 해결 방법 질문

0

354

1

[팁] 윈도우 cmd 커맨드

0

345

1

[팁]Chrome User Agent 아는법

0

324

1

실전 크롤링: 브라우저를 제어해서 트위터 사이트 로그인 하기 질문

0

252

1

동영상 강의 만드실 때 사용한 툴을 알려주실 수 있을까요?

0

234

1

CSS Selector 에서 질문이 있습니다.

0

432

2

pip install scrapy 오류

0

479

1

셀레니움 실행불가

0

1575

1

실전 크롤링: XPATH와 Selenium 활용해서 페이스북 로그인 하기 에서 질문이 있습니다.

0

224

1

언제 get_text()를 사용하고 또 언제 .text를 사용하나요?

0

284

1

강의교안자료 받을수있을까요?

0

261

1

[강의 9:27관련 질문] price, title 열 위치

0

157

1

div에 있는 클래스가 2개이면 어떻게 하나요?

0

365

1

css 셀렉터에 대해 질문이 있습니다.

0

142

1