python - 使用 python 获取 instagram 关注者列表

标签 python python-3.x

我编写的这段代码每 10 分钟为我提供 1000 个关注者,这是获得 1800 万关注者列表的缓慢过程。我想在更短的时间内访问 prada 的关注者列表。感谢您的回复,缓慢的过程是 instagram 限制错误。所以给个方法可以更快的获取follower列表。

 # 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 - 使用 python 获取 instagram 关注者列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55264169/

相关文章:

python - 基于属性值的字段计算器

python-3.x - 使用 Apache Airflow 提交和监控 SLURM 作业

Python:如何检查字符串是否包含列表中的元素并取出该元素?

Python Flask 应用程序使用 ajax 将远程服务器文本文件输出到网络服务器并在网页上显示 404 not found

python - 子进程运行/调用不起作用

Python 的新 `functools.cached_property` 错误或限制?

python - Pandas 从长到宽 reshape ,通过两个变量

python - 如何使用 PYZBAR 解码二维码 OpenCV - Python?

Python:select() 不会发出来自管道的所有输入信号

python - 导入错误 : No module named