Open mconigliaro opened 7 years ago
Hi there ! Well, the issue is, Instagram does not really load every comment, and it would be really tedious to actually exhaust the comments before switching to another post.
Still, the API gives you access to the comments IG loads first (no idea how they choose them, though):
from instaLooter import InstaLooter
looter = InstaLooter(directory="...", profile="...")
for media in looter.medias():
for comment in media['comments']['edges']:
print(comment['node']['owner']['username'], comment['node']['text'])
If this is still relevant: You may try Instaloader, a feature-rich Instagram downloader which is able to download and locally update the comments.
pip3 install instaloader
instaloader --comments PROFILE
@mconigliaro : I'm thinking about adding a --json-dump
flag that would dump the metadata extracted by instaLooter next to the proper image/video file in a JSON file. Would that work for you ?
Seems like it could be useful. I'm not sure what's included in the metadata though. I was really just interested in the comments.
The top (10, if I remember right ?) comments should be included inside of the dump, with username of the commenter and text of the comment. Unfortunately, scraping all the comments would be a pain, since IG uses a cursor system, which means you can only request sequentially, and doing this would (1.) be extremely slow and (2.) go way beyond the scope of this program.
It would be cool if there was a way to download comments too. Maybe store them in a text file with the same name of the image?