Python >
Selenium으로 크롬 제어
1
2
3
4
5
6
7
8
9
10
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
driver = webdriver.Chrome('chromedriver.exe')
driver.get('https://klee313.github.io')
WebDriverWait(driver, 30).until(EC.presence_of_all_elements_located((By.XPATH, "//div[@class='post-list-article']/li")))
all_list_elements = driver.find_element(By.XPATH, "div[@class='post-list-article']/li").find_element(By.XPATH, "./..").find_elements("./*") #div-li를 찾아, 그 요소의 부모노드를 찾고, 그 부모노드의 첫 자식노드들을 모두 찾는다.
html = driver.execute_script('return document.body.innerHTML')