taufikp/igscraper

基于PHP的Instagram网页爬虫。您可以从Instagram网页版获取账户信息、照片和视频

0.1.1 2018-10-24 10:51 UTC

This package is auto-updated.

Last update: 2024-10-02 02:01:18 UTC


README

此库基于Postaddictme的Instagram PHP爬虫

此库基于Instagram网页版。大多数情况下您无需使用OAuth。

代码示例

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

某些方法不需要认证

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

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

$instagram = Instagram::withCredentials('username', 'password', '/path/to/cache/folder/');
$instagram->login(); // will use cached session if you can force login $instagram->login(true)
$account = $instagram->getAccountById(3);
echo $account->getUsername();

使用代理请求

$instagram = new 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 taufikp/igscraper

composer require taufikp/igscraper

如果您没有composer

您可以在这里下载:这里

示例

请参阅示例这里