[MAC/ Python] VisualStudioCode 에서 Selenium 실행하기
Chrome에서 셀레니움을 이용한 동적 크롤링을 하기 위해서 크롬 드라이버를 설치해줘야한다!
1. 크롬 버전 확인
2. 버전에 맞는 Chrome 드라이버 설치하기
https://sites.google.com/a/chromium.org/chromedriver/downloads
Downloads - ChromeDriver - WebDriver for Chrome
WebDriver for Chrome
sites.google.com
나는 우선 Download에 경로를 두었다!
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.keys import Keys
#드라이버 초기화
from selenium.webdriver.common.by import By
s = Service('/Users/han-yujin/Downloads/chromedriver')
driver = webdriver.Chrome(service=s)
#URL 얻기
driver.get("https://www.google.com")
실행해보니까 오류가 났다
google.py:4: DeprecationWarning: executable_path has been deprecated, please pass in a Service object
mac OS에 chromeDriver를 설치하고 처음 실행하려고 할때 나는 오류이고, Mac OS가 기본적으로 chromeDriver binary를 차단하기 때문에 발생한다고 함! chromedriver의 binary의 quarantine을 해제시키는 명령어를 입력해야한다고 한다!
터미널로 이동해서 chromedriver가 있는 경로로 이동해주고
xattr -d com.apple.quarantine [설치경로]
이 명령어를 실행해줘야한다고 한다
실행하고 다시 명령어를 입력!
python3 google.py
명령어 실행하니 제대로 실행된다~
참고:
https://blog.naver.com/lynn1128/222310925258
Mac 환경에서, Selenium WebDriver 설치
#Python3 #Selenium Selenium Webdriver 홈페이지에서 파일을 다운로드받으면 안에 exe 파일이 들어있...
blog.naver.com
https://selenium-python.readthedocs.io/getting-started.html
2. Getting Started — Selenium Python Bindings 2 documentation
2.2. Example Explained The selenium.webdriver module provides all the WebDriver implementations. Currently supported WebDriver implementations are Firefox, Chrome, IE and Remote. The Keys class provide keys in the keyboard like RETURN, F1, ALT etc. from se
selenium-python.readthedocs.io
[Mac] Chrome driver 설치, Path 설정, mac 에러 해결
맥북을 사고 환경설정을 엉금엉금 영차영차 진행중이다...
velog.io