saqijaan / instagram-scraper
Instagram Scraper based on raiym/instagram-php-scraper . Get account information, photos and videos without any authorization. for some blocked endpoints you can just place a cookie file and can retrive data bypassing instagram blockage
Requires
- php: >=5.4.0
- ext-curl: *
- ext-json: *
- mashape/unirest-php: 3.0.*
- psr/simple-cache: ~1.0
Requires (Dev)
- phpfastcache/phpfastcache: ^7.1
- phpunit/phpunit: 5.5.*
README
This library is based on the Instagram web version. We develop it because nowadays it is hard to get an approved Instagram application. The purpose is to support every feature that the web desktop and mobile version support.
Dependencies
Code Example
$instagram = \InstagramScraper\Instagram::withCredentials('username', 'password'); $instagram->login(); $account = $instagram->getAccountById(3); echo $account->getUsername();
#Authentication via cookie
$instagram = \InstagramScraper\Instagram::setcookieFile('cookie.txt'); $instagram = new \InstagramScraper\Instagram(); $account = $instagram->getAccountById(3); echo $account->getUsername();
Some methods do not require authentication:
$instagram = new \InstagramScraper\Instagram(); $nonPrivateAccountMedias = $instagram->getMedias('kevin'); echo $nonPrivateAccountMedias[0]->getLink();
If you use authentication it is recommended to cache the user session. In this case you don't need to run the $instagram->login()
method every time your program runs:
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();
Using proxy for requests:
$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');
Installation
Using composer
composer.phar saqijaan/instagram-scraper
or
composer require saqijaan/instagram-scraper
If you don't have composer
You can download it here.
Examples
See examples here.