【发布时间】:2021-04-22 00:53:52
【问题描述】:
大家好,我正在尝试使用 selenium 和 python 过滤一些 instagram 用户,目标是关注所有用户的关注者多于关注者,但我不知道他为什么返回相同的结果:
以该帐户为例:
通常他必须打印我“追随者多于追随者”
我的代码:
followers = [] #list of url users
for follower in followers:
#Iterate into the list
scrap_follower = browser.find_element_by_xpath('/html/body/div[1]/section/main/div/header/section/ul/li[2]/a/span').get_attribute("title")
scrap_following = browser.find_element_by_xpath('/html/body/div[1]/section/main/div/header/section/ul/li[3]/a/span').text
follower_count = int(scrap_follower)
following_count = int(scrap_following)
browser.get(follower)
sleep(2)
followButton = browser.find_element_by_css_selector('button')
print(follower_count)
print(following_count)
if follower_count == 0:
pass
print("0 followers")
if follower_count > following_count :
print("have more followers than following")
pass
else:
print("eligible")
#Go to follow
我的控制台日志返回:
感谢您的帮助:)
【问题讨论】:
标签: python selenium if-statement instagram