Scraper to get the basic infos from
Get the webpage of an instagram account, no login required and retrieve thoses basic values and return it in an array key/pair value:
- Current date
- Uri of the instagram account
- Title
- Handler
- Followers
- Following
- Nb posts
- Just enter the account name in $account variable and run the script.
- The first time, it will scrap the url and return the basic infos and save a cachefile of the account page.
- Until the cachefile of the account is present, all subsequents run will read the cachefile instead.
- it will return a message from where the script toke the infos and an array of the key/value pair.
use app\instagramScraper;
use Tracy\Debugger;
require_once("vendor/autoload.php");
require_once("instagramScraper.php");
$account = "feliciaday"; //-- ex: feliciaday -> https://instagram.com/feliciaday
try {
$scraper = new instagramScraper($account);
dump($scraper->getDatas(TRUE)); //-- when set to TRUE, display the debugs message/values
} catch (Exception $e) {
die("<strong style='color:red'>ERROR</strong> : " . $e->getMessage());
}
getDatas() will return an array like this:
'date' => '2024-01-03 15:38:31'
'uri' => 'https://www.instagram.com/feliciaday/'
'title' => 'Felicia Day'
'handle' => '@feliciaday'
'followers' => '2M'
'following' => '288'
'nbposts' => '1,572'
- Flush the cache of the account page if older that x seconds.