inbo/instagram-php-scraper

Instagram PHP Scraper。无需任何授权即可获取账户信息、照片和视频

1.0.0 2020-10-29 12:24 UTC

This package is auto-updated.

Last update: 2024-09-29 05:56:00 UTC


README

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

依赖关系

代码示例

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

某些方法不需要身份验证

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

如果您使用身份验证,建议缓存用户会话。在这种情况下,您无需每次程序运行时都运行 $instagram->login() 方法。

use Phpfastcache\Helper\Psr16Adapter;

$instagram = \InstagramScraper\Instagram::withCredentials('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();

使用代理请求

$instagram = new \InstagramScraper\Instagram();
Instagram::setProxy([
    'address' => '111.112.113.114',
    'port'    => '8080',
    'tunnel'  => true,
    'timeout' => 30,
]);
// Request with proxy
$account = $instagram->getAccount('kevin');
Instagram::disableProxy();
// Request without proxy
$account = $instagram->getAccount('kevin');

安装

使用composer

composer.phar require raiym/instagram-php-scraper

composer require raiym/instagram-php-scraper

如果您没有composer

您可以从这里下载。

示例

请参阅这里的示例。

其他

Java库:https://github.com/postaddictme/instagram-java-scraper