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

前端 未结 4 1980
执笔经年
执笔经年 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:59

    Easily way is request with ?__a=1 like https://www.instagram.com/explore/tags/girls/?__a=1 and receive JSON without parsing HTML and window._sharedData =

    In json you can see page_info scope with end_cursor:

    "page_info": {
        "has_previous_page": false,
        "start_cursor": "1381007800712523480",
        "end_cursor": "J0HWCVx1AAAAF0HWCVxxQAAAFiYA",
        "has_next_page": true
    },
    

    use end_cursor to request next portion of images:

    https://www.instagram.com/explore/tags/girls/?__a=1&max_id=J0HWCVx1AAAAF0HWCVxxQAAAFiYA

    UPD:

    tag->media->nodes);
        if(!$json->tag->media->page_info->has_next_page) break;
        $url = $baseUrl.'&max_id='.$json->tag->media->page_info->end_cursor;
    }
    

提交回复
热议问题