python - 使用 python 获取 Instagram 关注者列表
问题描述
我编写的这段代码每 10 分钟给我 1000 个关注者,这是获得 1800 万关注者列表的缓慢过程。我想在更短的时间内访问 prada 的关注者列表。感谢您的回复,缓慢的过程是 instagram 限制错误。因此,请提供一种更快获得关注者列表的方法。
# Get instance
import instaloader
L = instaloader.Instaloader()
# Login or load session
L.login(username, password) # (login)
# Obtain profile metadata
profile = instaloader.Profile.from_username(L.context, "prada")
# Print list of followees
follow_list = []
count=0
for followee in profile.get_followers():
follow_list.append(followee.username)
file = open("prada_followers.txt","a+")
file.write(follow_list[count])
file.write("\n")
file.close()
print(follow_list[count])
count=count+1
# (likewise with profile.get_followers())
解决方案
主要瓶颈可能是从 instagram 中提取数据,但您可以通过在循环外仅打开和关闭一次来提高速度;你也不需要数组:
file = open("prada_followers.txt","a+")
for followee in profile.get_followers():
username = followee.username
file.write(username + "\n")
print(username)
file.close()
推荐阅读
- python - 如何在熊猫的列上应用公式
- php - PHP Laravel - 组合键 - 错误关系 *RECURSION*
- swift - 枚举Bundle中的sks文件
- java - 从字符串中删除停用词以创建集群
- python - 我可以在 iOS 应用程序中使用用 python 编写的聚类模型吗?
- c# - 如何使用 oracle 在 .net 框架控制台应用程序中创建实体数据模型?
- java - 不能让我的 JButtons 响应。除该面板外的所有内容都调整大小
- c - 编译器如何处理枚举中的符号常量?
- python - 在 Spyder 中创建和运行 Abaqus 几何,而不是打开 Abaqus 命令
- python - 如何在圆的周长上画圆?