百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
I

instagram-php-scraper

> 开发工具
开源

获取账户信息、照片、视频、动态和评论。

3.3K stars0 点赞1 次浏览
访问官网GitHub

工具介绍

获取账户信息、照片、视频、动态和评论。

Instagram PHP 爬虫

这个库基于 Instagram 网页版。我们开发它是因为如今很难获得一个已批准的 Instagram 应用程序。其目的是支持网页桌面版和移动版所支持的所有功能。

依赖

  • PHP >= 7.2
  • PSR-16
  • PSR-18

代码示例

php
use Phpfastcache\Helper\Psr16Adapter;

$instagram = \InstagramScraper\Instagram::withCredentials(new \GuzzleHttp\Client(), 'username', 'password', new Psr16Adapter('Files'));
$instagram->login();
$account = $instagram->getAccountById(3);
echo $account->getUsername();

有些方法不需要认证:

php
$instagram = new \InstagramScraper\Instagram(new \GuzzleHttp\Client());
$nonPrivateAccountMedias = $instagram->getMedias('kevin');
echo $nonPrivateAccountMedias[0]->getLink();

如果你使用认证,建议缓存用户会话。这样你就不必在每次程序运行时都执行 $instagram->login() 方法:

php
use Phpfastcache\Helper\Psr16Adapter;

$instagram = \InstagramScraper\Instagram::withCredentials(new \GuzzleHttp\Client(), 'username', 'password', new Psr16Adapter('Files'));
$instagram->login(); // will use cached session if you want to force login $instagram->login(true)
$instagram->saveSession();  //DO NOT forget this in order to save the session, otherwise have no sense
$account = $instagram->getAccountById(3);
echo $account->getUsername();

使用代理进行请求:

php
// https://docs.guzzlephp.org/en/stable/request-options.html#proxy
$instagram = new \InstagramScraper\Instagram(new \GuzzleHttp\Client(['proxy' => 'tcp://localhost:8125']));
// Request with proxy
$account = $instagram->getAccount('kevin');
\InstagramScraper\Instagram::setHttpClient(new \GuzzleHttp\Client());
// Request without proxy
$account = $instagram->getAccount('kevin');

安装

使用 Composer

bash
composer.phar require raiym/instagram-php-scraper phpfastcache/phpfastcache

或

bash
composer require raiym/instagram-php-scraper phpfastcache/phpfastcache

如果你没有 composer

你可以

Issues· 62 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

PHPinstagraminstagram-apiinstagram-clientinstagram-php-scraper

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类开发工具
定价开源

> 相关工具

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具