使用 Selenium 获取 IG 关注者未返回所有结果(缺少一些关注者)
我正在尝试使用 Selenium 抓取我的 IG 关注者列表。我已经成功登录,打开关注者选项卡并滚动到底部(以便加载所有关注者)。一切正常,一切都已加载,但是当我使用 find_elements_by_x 时,我没有得到所有结果(我可以通过在控制台中使用选择器来判断)。我已经使用不同的帐户和不同的选择器测试了这个问题,但几乎没有什么区别。看来问题的规模
对于例如。
63 个关注者:63 个结果
280 个关注者:260 个结果
520 个关注者:492 个结果
712 个关注者:大约 620 个结果
我已经使用 ul 中的各种元素进行了测试,我所做的最好的是
d = driver.find_elements_by_xpath("//*[@class='Jv7Aj mArmR MqpiF ']")
返回上述值,但仍然没有实际那么多。由于差异如此之小,因此很难找到问题所在。有什么想法吗?
我使用过:
driver.find_elements_by_class_name("wo9IH")
driver.find_elements_by_xpath("//*[@class='notranslate _0imsa ']")
driver.find_elements_by_xpath("//*[@class='Jv7Aj mArmR MqpiF ']")
driver.find_elements_by_xpath("//*[@class='_7UhW9 xLCgt qyrsm KV-D4 se6yk T0kll ']")
driver.find_elements_by_class_name("uu6c_")
driver.find_element_by_xpath('/html/body/div[6]/div/div/div/div[2]/ul/div/li['+str(i)+']/div/div[1]/div[2]/div[1]/span/a')
在控制台中,
$x("count(//*[@class='_7UhW9 xLCgt qyrsm KV-D4 se6yk T0kll '])")
返回正确数量的关注者
更新: 看来这是 Instagram 的问题。有时,当滚动时,您会在列表中看到不同数量的关注者,其中有一些缺失。太令人沮丧了。如果有人知道修复方法请告诉我。
I am trying to scrape my IG followers list using Selenium. I have managed to be able to login, open the followers tab and scroll to the bottom ( in order to load all the followers in). Everything works well, everything is loaded in, but when I use find_elements_by_x, I dont get all the results (I can tell from using the selector in the console). I have tested this issue with different accounts, and different selectors but with few differences. It also seems that the problem scales
For eg.
63 followers: 63 results
280 followers: 260 results
520 followers: 492 results
712 followers: around 620 results
I have tested using various elements in the ul, best I have done is
d = driver.find_elements_by_xpath("//*[@class='Jv7Aj mArmR MqpiF ']")
which returns the afformentioned values but still not as many as there actually are. Since the difference is so small, its difficult to find where the problem lies. Any ideas?
I have used:
driver.find_elements_by_class_name("wo9IH")
driver.find_elements_by_xpath("//*[@class='notranslate _0imsa ']")
driver.find_elements_by_xpath("//*[@class='Jv7Aj mArmR MqpiF ']")
driver.find_elements_by_xpath("//*[@class='_7UhW9 xLCgt qyrsm KV-D4 se6yk T0kll ']")
driver.find_elements_by_class_name("uu6c_")
driver.find_element_by_xpath('/html/body/div[6]/div/div/div/div[2]/ul/div/li['+str(i)+']/div/div[1]/div[2]/div[1]/span/a')
In the console,
$x("count(//*[@class='_7UhW9 xLCgt qyrsm KV-D4 se6yk T0kll '])")
returns the correct amount of followers
UPDATE:
It seems that this is an Instagram problem. Sometimes when scrolling you get a different amount of followers in the list, with some missing. So frustrating. If anyone knows a fix let me know.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论