인스타그램 자동 좋아요 프로그램 예제 연습을 하고 있는데 실제로 좋아요를 누르지는 않네요 ㅠ
아래 코드 중 뭐가 잘못일까요?
from selenium import webdriver
from myid import ID, PW
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
import time
driver = webdriver.Chrome('./chromedriver')
try:
driver.get('https://instagram.com')
time.sleep(2)
elem = driver.find_element_by_name('username')
elem.send_keys(ID)
elem = driver.find_element_by_name('password')
elem.send_keys(PW)
elem.send_keys(Keys.RETURN)
time.sleep(4)
driver.find_element_by_xpath('/html/body/div/div/div/div[3]/button[2]').click()
time.sleep(5)
elem = driver.find_element_by_xpath("//input[@placeholder='검색']")
elem.send_keys('키워드')
time.sleep(2)
elem.send_keys(Keys.ENTER)
time.sleep(2)
elem.send_keys(Keys.ENTER)
time.sleep(4)
links = driver.find_elements_by_xpath('//*[text()="인기 게시물"]//../..//a/..')
ac = ActionChains(driver)
for link in links:
ac.reset_actions()
ac.move_to_element(link)
ac.click()
ac.perform()
time.sleep(3)
try:
ac.reset_actions()
elem = driver.find_element_by_xpath('//*[@aria-label="좋아요"]')
ac.move_to_element(elem)
ac.click()
ac.perform()
time.sleep(5)
ac.reset_actions()
ac.send_keys(Keys.ESCAPE)
ac.perform()
time.sleep(2)
except Exception as e:
print(e)
input()
except Exception as e:
print(e)
finally:
driver.quit()
from myid import ID, PW
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
import time
driver = webdriver.Chrome('./chromedriver')
try:
driver.get('https://instagram.com')
time.sleep(2)
elem = driver.find_element_by_name('username')
elem.send_keys(ID)
elem = driver.find_element_by_name('password')
elem.send_keys(PW)
elem.send_keys(Keys.RETURN)
time.sleep(4)
driver.find_element_by_xpath('/html/body/div/div/div/div[3]/button[2]').click()
time.sleep(5)
elem = driver.find_element_by_xpath("//input[@placeholder='검색']")
elem.send_keys('키워드')
time.sleep(2)
elem.send_keys(Keys.ENTER)
time.sleep(2)
elem.send_keys(Keys.ENTER)
time.sleep(4)
links = driver.find_elements_by_xpath('//*[text()="인기 게시물"]//../..//a/..')
ac = ActionChains(driver)
for link in links:
ac.reset_actions()
ac.move_to_element(link)
ac.click()
ac.perform()
time.sleep(3)
try:
ac.reset_actions()
elem = driver.find_element_by_xpath('//*[@aria-label="좋아요"]')
ac.move_to_element(elem)
ac.click()
ac.perform()
time.sleep(5)
ac.reset_actions()
ac.send_keys(Keys.ESCAPE)
ac.perform()
time.sleep(2)
except Exception as e:
print(e)
input()
except Exception as e:
print(e)
finally:
driver.quit()
댓글 달기