-
카테고리
-
세부 분야
데이터 분석
-
해결 여부
미해결
파이어폭스 CLI 환경 예제 질문
21.07.10 00:29 작성 조회수 216
0
import sys
import io
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
import time
sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding='utf-8')
sys.stderr = io.TextIOWrapper(sys.stderr.detach(), encoding='utf-8')
firefox_options = Options()
firefox_options.add_argument("--headless") #CLI
driver = webdriver.Firefox(firefox_options=firefox_options,executable_path='C:\python\section3\webdriver\firefox\geckodriver')
#driver = webdriver.Chrome('C:\python\section3\webdriver\chrome\chromedriver')
#driver.set_window_size(1920,1280)
#driver.implicitly_wait(5)
driver.get("https://google.com")
#time.sleep(5)
driver.save_screenshot("C:\python\screenshot\website_ff1.png")
#driver.implicitly_wait(5)
driver.get('http://daum.net')
#time.sleep(5)
driver.save_screenshot("C:\python\screenshot\website_ff2.png")
driver.quit()
print("스크린샷 완료")
==================================================
경로도 틀리지 않았고 말씀하신대로 파일도 제대로 다 넣어있었고, 크롬에서의 예제는 제대로 실행되었는데 파이어폭스만 에러가 뜹니다
FileNotFoundError: [WinError 2] 지정된 파일을 찾을 수 없습니다
'geckodriver' executable needs to be in PATH.
답변을 작성해보세요.
0
좋은사람
지식공유자2021.07.11
안녕하세요.
경로가 맞지 않아 나오는 에러 같습니다.
아래 코드 보고 사용해보시구요!
from selenium import webdriver
driver = webdriver.Firefox(executable_path=r'your\path\geckodriver.exe')
driver.get('http://inventwithpython.com')
그래도 안되면 새로운 파이어폭스 드라이버로 한 번 다운받아서 진행해 보시구요!
https://github.com/mozilla/geckodriver/releases
답변 1