카테고리 없음

[Selenium] mac 환경세팅

arock 2022. 7. 23. 01:13
반응형

파이참 설치

https://www.jetbrains.com/ko-kr/pycharm/download/#section=mac

크롬 웹 드라이버 다운

다운받은 크롬 드라이버 selenium 폴더 안에 넣어주기

 

'chromedriver'은(는) Apple에서 악성 소프트웨어가 있는지 확인할 수 없기 때문에 열수 없습니다.

이 오류가 나는 경우에는 chromedriver가 있는 디렉토리에서 아래 명령어를 입력해 주면 된다.

$ xattr -d com.apple.quarantine chromedriver

 

Selenium 4. 대버전 사용 시 (DeprecationWarning: executable_path has been deprecated)

from selenium import webdriver

driver = webdriver.Chrome("./chromedriver")

DeprecationWarning: executable_path has been deprecated, please pass in a Service object driver = webdriver.Chrome("./chromedriver")

새로운 버전의 문법을 사용하라는 뜻인 것 같다.

 

해결방안

DeprecationWarning: executable_path has been deprecated 해결하기

  1. webdriver-manager 패키지를 설치합니다.
$ pip install webdriver-manager

2. 아래와 같이 Service 객체에 webdriver-manager의 ChromeDriverManager를 사용하여 크롬 드라이버를 다운받은 경로가 아닌 현재 OS에 설치된 크롬 브라우저를 사용하도록 수정합니다.(참고로, 'service' 키워드 인수는 Selenium 4부터 사용되는 거 같습니다.)

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
driver.get("<https://www.naver.com>")
  1. 네어버가 잘 실행되는 것을 볼 수 있습니다.

 

 

selenium이 꺼지면서 chrome 또한 꺼지는 현상

  • 해결 방안
  1. from selenium. webdriver. chrome. options import Options.
  2. chrome_options = Options()
  3. chrome_options. add_experimental_option("detach", True)
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager

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

driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
driver.get("<https://nid.naver.com/nidlogin.login?mode=form&url=https%3A%2F%2Fwww.naver.com>")

에러상황

이 오류가 나는 경우에는 chromedriver가 있는 디렉토리에서 아래 명령어를 입력해 주면 된다.

$ xattr -d com.apple.quarantine chromedriver

거슬리는 에러상황

from selenium import webdriver

driver = webdriver.Chrome("./chromedriver")

DeprecationWarning: executable_path has been deprecated, please pass in a Service object driver = webdriver.Chrome("./chromedriver")

서비스를 통과하는 객체를 사용해달라는 이야기인 듯하다.

  • 해결방안

DeprecationWarning: executable_path has been deprecated 해결하기

  1. webdriver-manager 패키지를 설치합니다.
$ pip install webdriver-manager
  1. 아래와 같이 Service 객체에 webdriver-manager의 ChromeDriverManager를 사용하여 크롬 드라이버를 다운받은 경로가 아닌 현재 OS에 설치된 크롬 브라우저를 사용하도록 수정합니다.(참고로, 'service' 키워드 인수는 Selenium 4부터 사용되는 거 같습니다.)
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
driver.get("<https://www.naver.com>")
  1. 네어버가 잘 실행되는 것을 볼 수 있습니다.

selenium이 꺼지면서 chrome 또한 꺼지는 현상

  • 해결 방안
  1. from selenium. webdriver. chrome. options import Options.
  2. chrome_options = Options()
  3. chrome_options. add_experimental_option("detach", True)
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager

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

driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
driver.get("<https://nid.naver.com/nidlogin.login?mode=form&url=https%3A%2F%2Fwww.naver.com>")

에러상황

이 오류가 나는 경우에는 chromedriver가 있는 디렉토리에서 아래 명령어를 입력해 주면 된다.

$ xattr -d com.apple.quarantine chromedriver

거슬리는 에러상황

from selenium import webdriver

driver = webdriver.Chrome("./chromedriver")

DeprecationWarning: executable_path has been deprecated, please pass in a Service object driver = webdriver.Chrome("./chromedriver")

서비스를 통과하는 객체를 사용해달라는 이야기인 듯하다.

  • 해결방안

DeprecationWarning: executable_path has been deprecated 해결하기

1. webdriver-manager 패키지를 설치합니다.

$ pip install webdriver-manager

2. 아래와 같이 Service 객체에 webdriver-manager의 ChromeDriverManager를 사용하여 크롬 드라이버를 다운받은 경로가 아닌 현재 OS에 설치된 크롬 브라우저를 사용하도록 수정합니다.

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
driver.get("https://www.naver.com")

3. 네어버가 잘 실행되는 것을 볼 수 있습니다.

 

selenium이 꺼지면서 chrome 또한 꺼지는 현상

해결 방안

  1. from selenium. webdriver. chrome. options import Options.
  2. chrome_options = Options()
  3. chrome_options. add_experimental_option("detach", True)
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager

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

driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
driver.get("<https://nid.naver.com/nidlogin.login?mode=form&url=https%3A%2F%2Fwww.naver.com>")
반응형