fczuardi / instagram-hashtag

Shell scripts to get metadata from instagram photos of a certain hashtag without the API, hacking browser calls instead. ( visaourbanaiz )
Other
7 stars 0 forks source link

Getting comments #4

Closed yarnball closed 8 years ago

yarnball commented 8 years ago

Hi,

Amazing work on this. Well done!

I'd like to somehow get comments (likes if possible) on the images too. What needs to be added to "metadata.sh" to achieve this?

fczuardi commented 8 years ago

Do you mean the number of comments and the number of likes? Or the full list of usernames that liked/comment on each photo? Or the full contents?

The script already gives you the media id of each photo on the resulting csv, with that in hands you can probably use the official API to get comments and likes:

https://www.instagram.com/developer/endpoints/comments/

https://www.instagram.com/developer/endpoints/likes/

yarnball commented 8 years ago

Would like the content of the comments themselves.

I have not been approved for API access so I won't be able to use their API.

Can you suggest another way?

Is the media ID the "code" part of the json? EG is it "BJU0eeEj-cY" from below?

  {
    "date": 1471684929,
    "owner": {
      "username": "egofin"
    },
    "code": "BJU0eeEj-cY",
    "display_src": "https://igcdn-photos-e-a.akamaihd.net/hphotos-ak-xpt1/t51.2885-15/e35/14033007_186402161780164_1837128116_n.jpg?ig_cache_key=MTMyMDkxMTM4MzAxODA3MTgzMg%3D%3D.2"
  },
fczuardi commented 8 years ago

hmm, the media id is not there, I am uploading a patch that will include id, comments count and likes count, just a moment…

fczuardi commented 8 years ago

the latest version of the scripts are including an id now, please test it and let me know if that's the right id

yarnball commented 8 years ago

Great, the latest version does include an ID, and a count of likes/comments!

Is there anyway, using your script, I can scrape the comment content?

fczuardi commented 8 years ago

not at the moment, the main script gets this info from the graphql query made by the tags page, that brings equivalent metadata of a media query like this (click the response button):

https://www.instagram.com/developer/endpoints/media/

To get the comments content would probably require one extra request per photo.

yarnball commented 8 years ago

But is it possible to get access to the comments without API access? Also, your latest commit doesn't seem to write the extra meta-data to the CSV. Mine only contains the image link, username, date and ID (I think- eg "BEOsnBFthwQ").

What needs to be done to get the link/comment count to in the .csv?

yarnball commented 8 years ago

Thanks- so I see that I need to go to instagram.com/p/"media-id" to see the id. But how can I integrate this in you script? Or even create a simple new one that still uses the cookie etc, and grabs the comments?