인프런 - 강의/웹 자동화 프로그램 만들기(Selenium) 11

12 - 사진 여러장 다운로드

from selenium import webdriver driver = webdriver.Chrome("./chromedriver") driver.get('https://www.google.com/search?q=dog&tbm=isch&hl=ko&hl=ko&tbs=sur%3Afc&ved=0CAIQpwVqFwoTCIj067ng1ecCFQAAAAAdAAAAABAC&biw=1368&bih=771') # # driver.find_element_by_xpath('//*[@id="islrg"]/div[1]/div[1]/a[1]/div[1]/img').screenshot('1.png') # driver.find_element_by_xpath('//*[@id="islrg"]/div[1]/div[2]/a[1]/div[1..

8 - 스크롤 내리면서 사진 찍기

from selenium import webdriver import time driver = webdriver.Chrome("./chromedriver") driver.get('https://www.google.com/search?q=cat&tbm=isch&hl=ko&hl=ko&tbs=sur%3Afc&ved=0CAIQpwVqFwoTCLix6ZzQ1ecCFQAAAAAdAAAAABAC&biw=1425&bih=742') driver.get_screenshot_as_file("data/test.png") for i in range(1,5) : scroll_index = i * 1000 # 1000, 2000, 3000, 4000 driver.execute_script("window.scrollTo(0," + s..

6 - 자동 댓글 달기

from selenium import webdriver import time driver = webdriver.Chrome("./chromedriver") driver.get("https://philosopher-chan.tistory.com/") driver.find_element_by_css_selector("#main > div > div:nth-child(1) > ul > li > div.article_content").click() # 반복문 만들기 count = 0 while count < 5 : driver.find_element_by_id("comment").send_keys("댓글 입력 예제입니다.") driver.find_element_by_name("name").send_keys("이..

5 - X Path로 눌러보기

from selenium import webdriver from selenium.webdriver.common.keys import Keys driver = webdriver.Chrome("./chromedriver") driver.get("https://www.google.com/") driver.implicitly_wait(10) driver.find_element_by_name("q").send_keys("인생이란") driver.find_element_by_name("q").send_keys(Keys.ENTER) # X Path란 경로 설정하는 것이다. driver.find_element_by_xpath("//*[@id='hdtb-msb-vis']/div[4]").click() driver.clo..