我正在制作instagram机器人。我已经从Internet复制了一些代码,但是现在我必须在中进行一些更改。问题是我无法单击“跟随”按钮。我需要进行修改,以跟随每个用户并转移到下一个用户,然后再次回溯。
for hashtag in hashtag_list:
tag += 1
try:
for x in range(1,200):
username = webdriver.find_element_by_xpath('/html/body/div[3]/div/div[2]/ul/div/li[1]/div/div[2]/div[1]/div/div/a').text
if username not in prev_user_list:
# If we already follow,do not unfollow
if webdriver.find_element_by_css_selector('body > div.RnEpo.Yx5HN > div > div.isgrP > ul > div > li:nth-child(39) > div > div.Pkbci > button').text == 'Follow':
webdriver.find_element_by_css_selector('body > div.RnEpo.Yx5HN > div > div.isgrP > ul > div > li:nth-child(39) > div > div.Pkbci > button').click() # unable to click this . also help me to jump on next user id.
new_followed.append(username)
followed += 1
# some hashtag stops refreshing photos (it may happen sometimes),it continues to the next
except:
continue