작성
·
1.2K
0
# 셀레니움 module import
# from selenium import webdriver
################################################################################################################################################################
# 2023.06.08 셀레니움 버전 업데이트로 인해 사용불가
################################################################################################################################################################
# 2023.05.08 selenium webdriver 사용방법 변경
# from selenium.webdriver.common.by import By
# from selenium import webdriver
# import time
# from time import sleep
# from bs4 import BeautifulSoup
# from selenium.webdriver.common.keys import Keys
# import requests
# import re
# import os
# # Dataframe
# import pandas as pd
# df = pd.DataFrame(columns=['idx','star','review'])
# chrome_options = webdriver.ChromeOptions()
# chrome_options.add_argument('--headless')
# chrome_options.add_argument('--no-sandbox')
# chrome_options.add_argument('disable-dev-shm-usage')
# chrome_options.add_argument("user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36")
# driver = webdriver.Chrome('chromedriver', options=chrome_options)
################################################################################################################################################################
# 2023.07.09 셀레니움 버전업으로 인한 코드 변경
################################################################################################################################################################
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
import time
from time import sleep
from bs4 import BeautifulSoup
import requests
import re
import os
# Dataframe
import pandas as pd
df = pd.DataFrame(columns=['idx','star','review'])
service = Service(executable_path="chromedriver")
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
driver = webdriver.Chrome(service=service, options=options)
안녕하세요. 해당 부분 다음과 같이 오류가 나오는데 어떻게 하면 좋을까요?
NoSuchDriverException Traceback (most recent call last)
<ipython-input-6-e1d24ca4db7f> in <cell line: 48>()
46 options.add_argument('--headless')
47 options.add_argument('--no-sandbox')
---> 48 driver = webdriver.Chrome(service=service, options=options)
2 frames
/usr/local/lib/python3.10/dist-packages/selenium/webdriver/common/driver_finder.py in get_path(service, options)
42
43 if path is None or not Path(path).is_file():
---> 44 raise NoSuchDriverException(f"Unable to locate or obtain driver for {options.capabilities['browserName']}")
45
46 return path
NoSuchDriverException: Message: Unable to locate or obtain driver for chrome; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location
답변 1
0
안녕하세요. 강의자입니다.
최근 1개월 이내에 셀레니움 라이브러리의 업데이트가 진행되면서 기존 코드로는 수정할 수 없게 되었습니다.
변경사항은 강의에 공유된 colab 코드를 확인해주시면 될 것 같습니다.
셀레니움 변경사항 확인한 내용
https://stackoverflow.com/questions/76428561/typeerror-webdriver-init-got-multiple-values-for-argument-options
파이썬의 모든 라이브러리는 오픈소스이다보니 버전업이 진행될때 기존 강의에서 공유드린 코드와 간혹 호환되지 않고 에러로 떨어지는 경우가 있습니다.
추후에도 다른 코드에서 유사한 경우 발생시 말씀주시면 가능한 빨리 처리하여 불편함이 없도록 도움드리겠습니다.
강의에 관심갖고 질문 주셔서 감사드리고 추가 문의사항 있으시면 언제든 말씀 부탁드리겠습니다.
감사합니다 :)