restyler/instagram-php-scraper

This package is abandoned and no longer maintained. No replacement package was suggested.

Profixied Instagram PHP Scraper. Get account information, photos and videos without any authorization, via smart proxy balancer.


README

Getting broken Instagram images when viewed in browser? (Apr 2021)

Take a look at https://github.com/postaddictme/instagram-php-scraper/issues/903#issuecomment-827537360

This repo contains RapidApi proxified version of Instagram scraper https://github.com/postaddictme/instagram-php-scraper due to difficulties with bypassing Instagram firewalls from regular data center ip ranges.

Why not just use residential proxy?

Even good residential proxies are banned by Instagram all the time. This scraper generally works much better than just using residential or mobile proxies with original scraper, because this one uses big network of high quality proxies, and retries and response quality control are handled automatically.

RapidAPI subscription page:

https://rapidapi.com/restyler/api/instagram40

This is a fork. If you need original non-profixied version of scraper, please use original package! https://github.com/postaddictme/instagram-php-scraper

RapidAPI proxy handles balancing and bypasses Instagram firewalls intelligently. Currently only public methods (not requiring auth, like analyzing public accounts and their posts and comments) of API are proxified, since Instagram may track ip addresses of login and mark your account as suspicious when proxy balancer switches ip address. So use withCredentials() with caution. See examples/getAccountByUsername.php and examples/getAccountMediasByUsername.php as safe examples of using proxified version.

Proxified methods:

  • getAccount()
  • getAccountById()
  • getMedias()
  • getMediasByTag()
  • getMediaByUrl()
  • getMediaByCode()
  • getCurrentTopMediasByLocationId()
  • getCurrentTopMediasByTagName()
  • getLocationById()

Dependencies

Code Example

Get account info by instagram user id

require_once 'vendor/autoload.php';

$instagram = new \InstagramScraper\Instagram(new \GuzzleHttp\Client());
$instagram->setRapidApiKey('YOUR-RAPID-API-KEY');
$account = $instagram->getAccountById(3);
echo $account->getUsername();

Get account medias by instagram username

$instagram = new \InstagramScraper\Instagram(new \GuzzleHttp\Client());
$instagram->setRapidApiKey('YOUR-RAPID-API-KEY');
$nonPrivateAccountMedias = $instagram->getMedias('kevin');
echo $nonPrivateAccountMedias[0]->getLink();

ATTENTION: do not use this proxified version for authenticated calls via withCredentials() method, please use original scraper instead!

This won't work and throw an exception in a proxified scraper:

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();

Installation

Using composer

composer require guzzlehttp/guzzle restyler/instagram-php-scraper

If you don't have composer

You can download it here.

Examples

See examples here.