硒未在Instagram上点击LIKE按钮

问题描述 投票:0回答:1

[出于某种原因,Instagram机器人似乎可以正常工作,但硒没有单击“赞”按钮。可能是什么问题?谢谢。

    unique_photos = len(pic_hrefs)
    for pic_href in pic_hrefs:
        driver.get(pic_href)
        time.sleep(2)
        driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
        try:
            time.sleep(random.randint(2, 4))
            like_button = lambda: driver.find_element_by_xpath('//span[@aria-label="Like"]').click()
            like_button().click()
            print('Liked!')
            for second in reversed(range(0, random.randint(18, 28))):
                print_same_line("#" + hashtag + ': unique photos left: ' + str(unique_photos)
                                + " | Sleeping " + str(second))
                time.sleep(1)
        except Exception as e:
            time.sleep(2)
        unique_photos -= 1
selenium click selenium-chromedriver
1个回答
0
投票

尝试一下:

 //article[1]//div[2]//section[1]//span[1]//button[1]//*[local-name()='svg']
© www.soinside.com 2019 - 2024. All rights reserved.