반응형
1. 사진 한장 가져오기
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
chrome_options = Options()
chrome_options.add_experimental_option("detach", True)
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
driver.get("<https://point-nine.com/layout/res/home.php?go=main>")
# 이미지 가져오기
driver.find_element(by=By.XPATH, value="//*[@id='slick-slide00']").screenshot("data/pointnine.png")
2. 사진 여러장 가져오기
화면에 보이지 않는 경우, 사진이 찍히지 않는다.
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
chrome_options = Options()
chrome_options.add_experimental_option("detach", True)
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
driver.get("<https://point-nine.com/layout/res/home.php?go=main>")
# 이미지 가져오기
for i in range(1,21) :
driver.find_element(by=By.XPATH, value="//*[@id='contents']/div/div[1]/div/ul/div/div/li[" + str(i) + "]/a/div[1]/img")\\
.screenshot("data/pointnine" + str(i) + ".png")
time.sleep(2)
반응형