파이썬 잘 하시는 분들 이 코드 뭐가 문제일까요?

글쓴이2020.05.09 22:30조회 수 401댓글 1

    • 글자 크기

인스타그램 자동 좋아요 프로그램 예제 연습을 하고 있는데 실제로 좋아요를 누르지는 않네요 ㅠ

아래 코드 중 뭐가 잘못일까요?

 

 

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()

 

    • 글자 크기

댓글 달기

번호 제목 글쓴이 날짜
공지 욕설/반말시 글쓰기 권한 영구 정지10 저렴한 개불알꽃 2019.01.26
공지 식물원 이용규칙 (2018/09/30 최종 업데이트) - 학생회 관련 게시글, 댓글 가능17 흔한 달뿌리풀 2013.03.04
23418 -13 건방진 양배추 2017.02.16
23417 9급 준비하시는 분 있나요?13 멋쟁이 애기메꽃 2016.01.12
23416 애교 많은 남자 싫나요??13 점잖은 회화나무 2013.05.22
23415 성적으로 흥분해본 경험...13 고상한 고마리 2013.11.29
23414 뜬금없지만 군대.....13 머리좋은 헛개나무 2013.06.11
23413 부전공 추천 좀 해주세요13 화난 큰까치수영 2018.07.07
23412 여교사 남교사13 꼴찌 댑싸리 2018.11.15
23411 복수전공으로 어떤 학과를 선택해야할지. (심리,사회)13 코피나는 원추리 2013.08.22
23410 오늘 토익 난이도 어땠나요?13 뚱뚱한 물아카시아 2018.03.31
23409 중도에서 그냥 책만 읽어도 되나요13 귀여운 마름 2015.07.03
23408 [레알피누] 경영 부전공하시는분들!13 신선한 삼지구엽초 2015.08.09
23407 행정고시 일년안에 붙을수 있을까요?!!13 불쌍한 쇠별꽃 2017.06.22
23406 [레알피누] 혹시 승무원준비13 더러운 까마중 2015.09.16
23405 배고플때마다 단백질보충제먹으면 어떻게 됨??13 짜릿한 뽕나무 2018.06.14
23404 cpa치고 싶어서 공부중인데... ㅠㅠㅠㅠㅠ13 털많은 매화나무 2020.02.04
23403 경기가 살아날 만한 좋은 기사가 안 보인다..13 기발한 솔새 2020.03.11
23402 하계 단기어학연수 영국 다녀오신분!13 침울한 백선 2017.02.27
23401 이제 긱사 통금 6시까진가요?13 명랑한 백당나무 2019.03.18
23400 실생활에 쓸수있는 법을 공부하고 싶은데 머부터 해야할까요?13 날씬한 실유카 2013.10.10
23399 컴잘알 형들 급해요....(긴글주의ㅠㅠ)13 황송한 금방동사니 2018.04.25
첨부 (0)