专用Instagram API的客户端接口。

instagscrape的Python项目详细描述


Instagram私有API

instagram私有api的python包装器,不依赖第三方。同时支持应用程序和Web API。

Python 2.7, 3.5ReleaseDocsBuild

概述

我写这篇文章是为了在Instagram限制开发者访问时访问它的API。因为这意味着用official public API实现parity,所以公共api中不可用的方法通常具有较低的优先级。

有问题吗?在提交问题之前,请检查docs

功能

可以使用extension module帮助完成常见任务,如分页、发布照片或视频。

文档

文档可在https://instagram-private-api.readthedocs.io/en/latest/

安装

使用pip安装:

pip install git+https://git@github.com/ping/instagram_private_api.git@1.6.0

要更新:

pip install git+https://git@github.com/ping/instagram_private_api.git@1.6.0 --upgrade

要使用最新的回购代码进行更新:

pip install git+https://git@github.com/ping/instagram_private_api.git --upgrade --force-reinstall

在Python2.7和3.5上测试。

用法

app API client模拟官方应用程序,并具有一组更大的函数。web API client的集合较小,但可以在不登录的情况下使用。

您的选择将取决于您的用例。

^{}^{}是关于如何使用客户端的详细示例代码的良好来源,包括保存auth cookie以供重用的简单方法。

选项1:使用official app's API

frominstascrapeimportClient,ClientCompatPatchuser_name='YOUR_LOGIN_USER_NAME'password='YOUR_PASSWORD'api=Client(user_name,password)results=api.feed_timeline()items=[itemforiteminresults.get('feed_items',[])ifitem.get('media_or_ad')]foriteminitems:# Manually patch the entity to match the public api as closely as possible, optional# To automatically patch entities, initialise the Client with auto_patch=TrueClientCompatPatch.media(item['media_or_ad'])print(item['media_or_ad']['code'])

选项2:使用official website's API

frominstascrape.webimportClient,ClientCompatPatch,ClientError,ClientLoginError# Without any authenticationweb_api=Client(auto_patch=True,drop_incompat_keys=False)user_feed_info=web_api.user_feed('329452045',count=10)forpostinuser_feed_info:print('%s from %s'%(post['link'],post['user']['username']))# Some endpoints, e.g. user_following are available only after authenticationauthed_web_api=Client(auto_patch=True,authenticate=True,username='YOUR_USERNAME',password='YOUR_PASSWORD')following=authed_web_api.user_following('123456')foruserinfollowing:print(user['username'])# Note: You can and should cache the cookie even for non-authenticated sessions.# This saves the overhead of a single http request when the Client is initialised.

避免重新登录

建议您保存/缓存身份验证cookie详细信息,以避免每次进行api调用时都登录。过度登录是一个确定的方式,使您的帐户标记为删除。还建议将客户端详细信息(如用户代理等)与身份验证详细信息一起缓存。

保存的身份验证cookie最多可重复使用90天

支架

在提交问题报告或请求之前,请确保查看contributing documentation
在这里向原投稿人捐款:@ping

法律

免责声明:本声明不受Instagram的牵连、认可或认证。这是一个独立的非官方api。严格来说,不适用于垃圾邮件。使用风险自负。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java找不到适合makeText的方法   如何将java数组转换为prolog列表并使用它进行jpl查询?   安卓中显示ArrayList的java子类ArrayAdapter   Java8GroupingBy到包含列表的映射中   java Json字符串,带有要映射的嵌套对象<string,string>   java Hibernate中的包和列表有什么区别?   java Spring REST模板指定Jackson视图   java如何在继承的类中返回字符串?   调试Java ArrayQue删除和轮询方法错误   带有NetBeans 7.4的java JSP自定义标记Struts2   java无法从加载jar文件。蝙蝠锉   无法解析java image_项“未显示在下拉列表中且无法键入”   jdoDetachedState设置为null的java查询实体   scala使用Cypher CREATE命令和属性映射,来自Java   minecraft中的java/me并没有被我编写的插件禁用   java Cucumber框架设置   java以奇怪的方式遍历LinkedList?   java JPA将布尔字段配置为保留为整数   月球着陆器中的java Android垃圾收集