inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

[신규 개정판] 이것이 진짜 크롤링이다 - 실전편 (인공지능 수익화)

2단계 - 나무태그 찾기

selenium 에서 웹드라이버를 불러오지 못하는 오류납니다~

6286

오유라

작성한 질문수 7

0

Microsoft Windows [Version 10.0.19045.3448]

(c) Microsoft Corporation. All rights reserved.

C:\Users\user\data>C:/Users/user/AppData/Local/Programs/Python/Python311/python.exe c:/Users/user/data/sel.py

Traceback (most recent call last):

File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\common\driver_finder.py", line 38, in get_path

path = SeleniumManager().driver_location(options) if path is None else path

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\common\selenium_manager.py", line 76, in driver_location

browser = options.capabilities["browserName"]

^^^^^^^^^^^^^^^^^^^^

AttributeError: 'str' object has no attribute 'capabilities'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "c:\Users\user\data\sel.py", line 33, in <module>

File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 45, in init super().__init__(

File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 51, in init

self.service.path = DriverFinder.get_path(self.service, options)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\common\driver_finder.py", line 40, in get_path

msg = f"Unable to obtain driver for {options.capabilities['browserName']} using Selenium Manager."

^^^^^^^^^^^^^^^^^^^^

python 웹-크롤링

답변 1

0

스타트코딩

안녕하세요~!

수강생님 코드를 어떻게 작성하셨을까요?

0

오유라


from selenium import webdriver

from selenium.webdriver.common.by import By

from selenium.webdriver.common.keys import Keys

from selenium.webdriver.chrome.options import Options

import time

import sys
sys.executable

chrome_options = Options()

chrome_options.add_experimental_option("detach", True)

# 불필요한 에러 메시지 없애기

chrome_options.add_experimental_option("excludeSwitches", ["enable-logging"])



# 브라우저 생성
browser = webdriver.Chrome('C:/Users/user/Downloads/data/chromedriver.exe')


browser = webdriver.Chrome(options=chrome_options)
browser.get('https://www.naver.com')
browser.implicitly_wait(10)

browser.find_element_by_css_selector('a.nav.shop').click()
time.sleep(2)



search = browser.find_element_by_css_selector('input._searchInput_search_text_3CUDs')

search.click()

# 새창을 바라보게 만들기
new_window = browser.window_handles[1]

browser.switch_to.window(new_window)


# 화면 최대화 해야지 검색창이 보임

browser.maximize_window()

0

스타트코딩

강의를 찍은 시점에서 셀레니움이 조금 업데이트가 있었는데요

아래와 같은 방법으로 크롬 브라우저를 띄워주시면 됩니다.

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
import time

chrome_options = Options()
chrome_options.add_experimental_option("detach", True)

# 불필요한 에러 메시지 없애기
chrome_options.add_experimental_option("excludeSwitches", ["enable-logging"])

# 브라우저 생성
browser = webdriver.Chrome(options=chrome_options)
browser.get('https://www.naver.com')

 

그리고 (BONUS) 셀레니움 ver 4.0 가이드 + 크롬 드라이버 자동으로 다운 받는 법

영상 시청 후 find_element, find_elements 명령어 사용방법을 학습해 보시기 바랍니다 :)

 

 

 

 

셀레니움 환경설정 오류

0

45

2

네이버 로그인 관련

0

252

2

안녕하세요 셀레니움에 대해서 질문

0

85

1

크롤링 연습사이트 문의

0

95

2

선택자 질문

0

71

2

'특정 요소가 나타날 때까지 스크롤' 부분 에러

0

76

2

자동 로그인 질문

0

86

2

44강 제목, 링크

0

105

1

원하는 값이 없을 때

0

89

2

크롤링한 링크가 엑셀로 들어가면 작동이 안되요

0

227

2

셀레니움 PDF자료는 받을 수 있나요

0

100

2

글목록 추출하기

0

97

2

메일 자동화 로그인 중복방지문자해결 오류 및 명시적 대기 질문

0

88

2

강의 노트가 어디에 있는건가요?

0

80

2

강의 커리큘럼 질문

0

97

1

조건문 else 사용하지 않는 이유

0

75

2

셀레니움으로 접근할 수 없는 경우

0

95

2

웹페이지 변경

0

70

2

자바스크립트로 태그 선택 시 질문입니다.

1

64

2

수료증은 어떻게 받나요?

0

117

2

class명을 활용하여 선택자를 만들지 않는 경우..?

0

60

2

드라이버가 안 열려요

0

79

2

이거 해결방법 아시는 분?

0

121

2

네이버 지식인 크롤링..

0

201

2