강의

멘토링

커뮤니티

Cộng đồng Hỏi & Đáp của Inflearn

Hình ảnh hồ sơ của bigsea0070390
bigsea0070390

câu hỏi đã được viết

Tạo ứng dụng thu thập dữ liệu web bằng Python

01 - Tìm hiểu môi trường web 1

크롤링 오류

Viết

·

216

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

Câu trả lời

Câu hỏi này đang chờ câu trả lời
Hãy là người đầu tiên trả lời!
Hình ảnh hồ sơ của bigsea0070390
bigsea0070390

câu hỏi đã được viết

Đặt câu hỏi