notslang / instagram-screen-scrape

scrape public instagram data w/out API access
https://npmjs.com/package/instagram-screen-scrape
GNU General Public License v3.0
162 stars 38 forks source link

Support getting additional photo sizes #7

Open raiym opened 8 years ago

raiym commented 8 years ago

Scraper gives only 640x640 photo urls even if photo exists in 1080x1080

notslang commented 8 years ago

Yeah, over in posts.coffee:70, we just pick the standard resolution. However, looking at an example of the response, it seems like you can derive the other URLs from the standard resolution URL:

{
  "images": {
    "low_resolution": {
    "url": "https://scontent-ord1-1.cdninstagram.com/t51.2885-15/s320x320/e35/12531128_1720535754825405_615608517_n.jpg?ig_cache_key=MTE4MzA1OTUyNjk1ODY0ODUwMQ%3D%3D.2",
    "width": ​320,
    "height": ​320
    },
    "thumbnail": {
      "url": "https://scontent-ord1-1.cdninstagram.com/t51.2885-15/s150x150/e35/12531128_1720535754825405_615608517_n.jpg?ig_cache_key=MTE4MzA1OTUyNjk1ODY0ODUwMQ%3D%3D.2",
      "width": ​150,
      "height": ​150
    },
    "standard_resolution": {
      "url": "https://scontent-ord1-1.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/12531128_1720535754825405_615608517_n.jpg?ig_cache_key=MTE4MzA1OTUyNjk1ODY0ODUwMQ%3D%3D.2",
      "width": ​640,
      "height": ​640
    }
  }
}

I would much rather give some single standard URL for the resource, or a simple media ID with a function for formatting that ID into a URL for whatever representation of the image you want, and I'd gladly take a PR for that.

raiym commented 8 years ago

JSON.stringify(rawPost.images.low_resolution.url).replace('320x320', '1080x1080')

This worked pretty well for me. Somehow instagram stores photos in these urls even if there is no 1080px image

raiym commented 8 years ago

I created service backupitfor.me on top of your library. Any plans to add 1080x1080 support natively?

fabiocaccamo commented 8 years ago

I just founded and tested this scraper and it works very well. The only problem is that the image returned is not at the highest resolution.

Actually the highest resolution image url can be founded in meta property og:image, check it here: https://github.com/soimort/you-get/blob/develop/src/you_get/extractors/instagram.py