Created
July 5, 2016 08:55
-
-
Save wgroenewold/7c4aaa48a669f1069a80b1217e4c4e38 to your computer and use it in GitHub Desktop.
Fuck you Instagram
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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