Skip to content

Instantly share code, notes, and snippets.

@wgroenewold
Created July 5, 2016 08:55
Show Gist options
  • Save wgroenewold/7c4aaa48a669f1069a80b1217e4c4e38 to your computer and use it in GitHub Desktop.
Save wgroenewold/7c4aaa48a669f1069a80b1217e4c4e38 to your computer and use it in GitHub Desktop.
Fuck you Instagram
<?php
$tag = 'horse';
$scrape = scrape_ig_tag($tag);
function scrape_ig_tag($tag) {
$ig_url = file_get_contents('https://www.instagram.com/explore/tags/'.$tag.'/'); // instagrame tag url
$shards = explode('window._sharedData = ', $ig_url);
$ig_json = explode(';</script>', $shards[1]);
$ig_data = json_decode($ig_json[0], TRUE);
return $ig_data; // the whole shebang
}
$results = array();
//clean this crap
foreach($scrape['entry_data']['TagPage'][0]['tag']['media']['nodes'] as $crap){
$results[] = array(
'img' => $crap['thumbnail_src'],
'dimensions' => $crap['dimensions'],
'caption' => $crap['caption']
);
}
foreach($results as $data){
echo '<img src="' . $data['img'] . '" />';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment