How to get the followers of a person as well as comments under the photos in instagram using scrapy?

笑着哭i 提交于 2019-12-04 17:12:32

By using a code similar to the following, I was able to grab the text of a comment:

 29             code = json_response["user"]["media"]["nodes"][1]["code"]
 30             sub_post_url = "https://www.instagram.com/p/"+code+"/?__a=1"
 31             print(sub_post_url)
 32             sub_response = requests.get(sub_post_url).json()
 33             pprint(sub_response)
 34             print(sub_response["media"]["comments"]["nodes"][7]["text"])

or iterate over all comments by:

34             for i in range(len(sub_response["media"]["comments"]["nodes"])):
 35                 print(sub_response["media"]["comments"]["nodes"][i]["text"])
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!