inflearn logo
강의

講義

知識共有

Pythonを使用したWeb Crawlingアプリケーションの作成

01 - Web環境の理解1

크롤링 오류

228

bigsea0070390

投稿した質問数 1

0

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
import time

from urllib.request  import urlopen
from urllib.parse import quote_plus
from bs4 import BeautifulSoup  
from requests_html import HTMLSession
import time
driver = webdriver.Chrome() 

session = HTMLSession()

baseUrl = 'https://www.courtauction.go.kr/'

driver.get(baseUrl)
print(driver.window_handles)
time.sleep(3)
driver.switch_to.window(driver.window_handles[1])
driver.close()
driver.switch_to.window(driver.window_handles[0])
print(driver.window_handles) 


f = open('jquery-3.4.1.min.js''r')
driver.execute_script(f.read())
element = driver.find_element_by_xpath("/html/body/div/div/div[4]/div[3]/div[2]/div[1]/form/div/div")
element.click()
print(element) 
#main_btn > a
#javascript = driver.find_element_by_xpath('//*[@id="main_btn"]/div') 
#javascript.click()

f.close()
이렇게 크롤링을 했는데 아래처럼 오류가 나요 이유를 모를겠씁니다
PS C:\Users\USER\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\selenium\webdriver> python py4.py DevTools listening on ws://127.0.0.1:57644/devtools/browser/ce3a0c10-1e5f-448a-9768-7a3731b4bdba ['CDwindow-761E40B9B36801AA66BCBD3A4BD8C663'] KLIB_SelfTest return : KLR_OK ['CDwindow-761E40B9B36801AA66BCBD3A4BD8C663'] Traceback (most recent call last): PS C:\Users\USER\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\selenium\webdriver> python py4.py DevTools listening on ws://127.0.0.1:58047/devtools/browser/b5b368df-a040-40c0-b20c-9754ab89abe0 PS C:\Users\USER\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\selenium\webdriver> python py4.py DevTools listening on ws://127.0.0.1:58108/devtools/browser/9d932f6e-10bc-444a-8254-1d45d4a1d35d ['CDwindow-FCDFF87FC00982E5E47F38B05CCA7CD5'] KLIB_SelfTest return : KLR_OK ['CDwindow-FCDFF87FC00982E5E47F38B05CCA7CD5'] Traceback (most recent call last): File "py4.py", line 29, in <module> element = driver.find_element_by_xpath("/html/body/div/div/div[4]/div[3]/div[2]/div[1]/form/div/div") File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 394, in find_element_by_xpath return self.find_element(by=By.XPATH, value=xpath) File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 976, in find_element return self.execute(Command.FIND_ELEMENT, { File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div/div/div[4]/div[3]/div[2]/div[1]/form/div/div"} (Session info: chrome=83.0.4103.106)

웹-크롤링 python

回答 0

작업형 1 유형 부분

0

9

1

수강평 이벤트

0

15

2

작업형 1 (삭제예정, 구 버전)

0

28

2

강의노트는 어디있나요?

0

15

1

노션 학습 자료 권한 요청

0

15

1

수강기간 연장 문의드립니다.

0

20

1

2유형 레이블 인코딩 VS 원핫 인코딩

0

21

3

part2강의 문의사항입니다.

0

18

2

수강기간 연장 문의드립니다.

0

26

1

인덱스 슬라이싱

0

26

2

코드를 첨부해야하는 이유가 있나요?

0

20

2

소리가 겹쳐서 들려요

0

19

2

데스크톱과 노트북 연결

0

26

1

dict, zip

0

21

2

노션 : 파트3번 링크와 권한 , 파트4번 권한요청, 파트 5번도 미리 요청 드립니다.

0

27

4

6-6 실습 문의

0

23

2

미션 06-02

0

24

2

yes24 수집 md 파일 만들 때

0

24

2

python main.py 실행시 게임이 실행이 안돼요

0

27

2

antigravity 대신 cursor를 활용해도 되나요?

0

25

1

dmoz.org에 접속하면 400 Bad Request에러가 납니다

0

224

0

패키지 설치부분

0

317

0

블로그에 ppt와 강의영상을 토대로 정리를 해도 될까요??

0

304

1

안녕하세요. 궁금한 점이 있습니다.

0

223

0