How to get all images of hashtag in Instagram without API?

前端 未结 4 1951
执笔经年
执笔经年 2020-12-08 03:40

This is the code that I used to get images of hashtag without API. I do not want to use any credentials. It does not require me to add either client_id or acces

4条回答
  •  时光说笑
    2020-12-08 03:51

    This one works for me perfectly.

    I only needed the thumbnails. You can easily change it to full size image. This example does not solve pagination, but you can do that from @ilyapt answer.

    $tag = 'coronavirus';
    $json = json_decode(file_get_contents("https://www.instagram.com/explore/tags/$tag/?__a=1", true));
    
    $i = 0;
    foreach($json->graphql->hashtag->edge_hashtag_to_media->edges as $key => $value) {
        $img = $value->node->thumbnail_resources[0]->src;
        echo "";
        if (++$i == 9) break; // limit to the 9 newest posts
    }
    

提交回复
热议问题