一个简单的Instagram Web API库
instpector的Python项目详细描述
仪器
一个用python编写的简单instagram web api库。不需要selenium或webdriver。
支持启用双因素身份验证的登录。
安装
pip install instpector
示例用法
frominstpectorimportInstpector,endpointsinstpector=Instpector()# Login into Instagram's webinstpector.login("my_username","my_password")# Get the profile of any user, for example 'some_username'profile=endpoints.factory.create("profile",instpector)insta_profile=profile.of_user("some_username")print(insta_profile)# id, followers_count, following_count, is_private, ... # Iterate all followers of 'some_username'followers=endpoints.factory.create("followers",instpector)forfollowerinfollowers.of_user(insta_profile.id):print(follower)# id, username, full_name, ...# Logoutinstpector.logout()
使用2fa
要使用双因素身份验证登录,请在Instagram的应用程序上生成2FA密钥,并在使用instpector
登录时提供代码。下面的示例使用pytop
演示用法:
frompyotpimportTOTPfrominstpectorimportInstpector,endpointsinstpector=Instpector()totp=TOTP("my_2fa_key")# Input without spaces# Login into Instagram's webinstpector.login("my_username","my_password",totp.now())
在examples
目录中检查更多。
可用端点
- 追随者
- 跟随
- 时间线
- 配置文件
- 故事卷
- 故事
更多信息
开发依赖性
- 请求
测试
在
tests
目录中创建一个样本内容为pytest.sample.ini
的pytest.ini
文件。添加您的帐户信息。
使用
运行pytest
:
(env)$ pytest -qs tests
免责声明
本工具不属于Instagram或其任何附属公司或子公司,也不由Instagram或其任何附属公司或子公司授权、维护或背书。使用风险自负。
许可证
根据麻省理工学院的许可证。