我用python写了一个Instagram喜欢的机器人。喜欢的功能是:
unique_photos = len(pic_hrefs)
for pic_href in pic_hrefs:
driver.get(pic_href)
time.sleep(2)
try:
time.sleep(random.randint(4, 15))
like_button = lambda: driver.find_element_by_class_name("_8-yf5 ").click()
like_button().click()
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(2)
except Exception as e:
time.sleep(2)
unique_photos -= 1
我现在要添加一个具有相似限制的Likecount。我还想检查我是否已经喜欢上一张照片,然后跳过该张照片。我该怎么办?
是的,咏叹调标签会更改。我这样尝试过:
like_xpath ='//span[@aria-label="Gefällt mir"]'
liked_xpath = '//span[@aria-label="Gefällt mir nicht mehr"]'
unliked = self.driver.find_elements_by_xpath(like_xpath)
liked = self.driver.find_elements_by_xpath(liked_xpath)
以及如果喜欢的人...但它没有用