xpath & selenium을 활용한 크롤링(crawing)
- 최초 등록일
- 2021.12.30
- 최종 저작일
- 2021.05
- 10페이지/ MS 파워포인트
- 가격 5,000원
소개글
"xpath & selenium을 활용한 크롤링(crawing)"에 대한 내용입니다.
목차
없음
본문내용
제목 : xpath & selenium을 활용한 크롤링
환경 :
Python : 3.9.5
Selenium : 4.1.0
chromedriver : 96.0.4664.45
※ selenium : 웹 브라우저를 띄우고 접속된 사이트에 대해 크롤링을 해주는 도구
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
driver = webdriver.Chrome()
driver.get('https://www.google.com/search?q=sns')
for count in range (1,11) :
try :
xpath=('/html/body/div[7]/div/div[9]/div[1]/div/div[2]/div[2]/div/div/div[%s]/div/div/div[1]/a/h3' % count)
driver = WebDriverWait(driver, 2).until(EC.presence_of_element_located((By.XPATH, xpath)))
element = driver.find_element(By.XPATH, xpath)
참고 자료
없음