강의

멘토링

로드맵

Inflearn Community Q&A

blackcoding911's profile image
blackcoding911

asked

Introduction to Python and Creating Various Automated Applications Using Web Crawling

Hands-on Scraping and Parsing Without a Web Browser (1) - Inflearn

파이어폭스 CLI 환경 예제 질문

Written on

·

282

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. 
python웹-크롤링

Quiz

HTTP 통신의 주된 특징은 무엇인가요?

연결 지향적이며 상태를 유지합니다.

비연결 및 무상태 특성을 가집니다.

항상 서버와 클라이언트 간 영구 연결을 유지합니다.

상태 유지를 위해 매 요청마다 로그인 정보를 포함해야 합니다.

Answer 1

0

niceman님의 프로필 이미지
niceman
Instructor

안녕하세요.

경로가 맞지 않아 나오는 에러 같습니다.

아래 코드 보고 사용해보시구요!

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

blackcoding911's profile image
blackcoding911

asked

Ask a question