Home Access Instagram media without using Instagram API
Reply: 2

Access Instagram media without using Instagram API

minimalpop
1#
minimalpop Published in 2018-02-10 17:39:31Z

I have previously used the Instagram API to access public images by tag, location, etc. I created a new application and retrieved an access_token, but these public media searches no longer return any data. However, they return 200 statuses.

On the documentation, it says "applications not accepted" for the the public_content scope, which is required for these searches. So, it appears that the Instagram API is being deprecated.

This makes zero sense to me (which is why I'm posting here), since these types of searches are at the core of so many applications and services. I'm also confused by how these requests still return 200 responses.

I was wondering if there are other methods to access public content on Instagram, such as using the Facebook API. Does Instagram wants to entirely prevent developers from accessing public photos? Or is this just to port the Instagram API features to another API, like Facebook?

ABelikov
2#
ABelikov Reply to 2018-02-14 10:39:35Z

If you can't use API you can try to scrap HTML.

You can get html for needed tag by link https://www.instagram.com/explore/tags/[TAG]/

Eg

curl https://www.instagram.com/explore/tags/telegram/

Then you must find sting wich starts from "<script type="text/javascript">window._sharedData =" There will be JSON wich easy to parse with any popular languges.

From this data you can get list of "shortcode" of posts. Eg "BfLErJ_hzak"

Next you can get post-detail by link https://www.instagram.com/p/[SHORTCODE]/?__a=1

Eg.

curl https://www.instagram.com/p/BfLErJ_hzak/?__a=1

It returns JSON data. See example

{"graphql":{"shortcode_media":{"__typename":"GraphImage","id":"1714484640997652132","shortcode":"BfLErJ_hzak","dimensions":{"height":1080,"width":1080},"gating_info":null,"media_preview":"ACoqamHCl0YsgAyQeMc//qp8DFiXPUmrTTbarwgmUlfu8HHHGaHqES0yqT6ZH61Pa9vp/SlQIi7Rg4/X/P6Utuc84K4B4NG2gbkyj7v5/pQZcEinL1HsP8KhKE8+tMRkzHiqQcJzz/jVi4gOMpwfaqRmLrsfr09zTA3YYzjcR+A5/wA/hVvB2lhxxkf4H61BZy70GRgjj644zVxOmDUgCtnnvipQABiqhyhyPX9Kk88e1MCo6dR3rKeLKhx+PtW0/QfQVmwnlx7mmI0IYR5akcHAqfdtOTTLf/Vr9KbLUjJnCnv15qgUWi2JKHPPOP50/NNAf//Z","display_url":"https://instagram.fhel3-1.fna.fbcdn.net/vp/d44e27e253f499ab84bd5944c8a93313/5B044F81/t51.2885-15/e35/27581038_2488346268057255_6612776414812831744_n.jpg","display_resources":[{"src":"https://instagram.fhel3-1.fna.fbcdn.net/vp/0e2d4f8e3b780cc4fba827e2afbcd7bd/5B180DAB/t51.2885-15/s640x640/sh0.08/e35/27581038_2488346268057255_6612776414812831744_n.jpg","config_width":640,"config_height":640},{"src":"https://instagram.fhel3-1.fna.fbcdn.net/vp/2d7cba2b057809aa589ab589baed3aff/5B087C45/t51.2885-15/s750x750/sh0.08/e35/27581038_2488346268057255_6612776414812831744_n.jpg","config_width":750,"config_height":750},{"src":"https://instagram.fhel3-1.fna.fbcdn.net/vp/d44e27e253f499ab84bd5944c8a93313/5B044F81/t51.2885-15/e35/27581038_2488346268057255_6612776414812831744_n.jpg","config_width":1080,"config_height":1080}],"is_video":false,"should_log_client_event":false,"tracking_token":"eyJ2ZXJzaW9uIjo1LCJwYXlsb2FkIjp7ImlzX2FuYWx5dGljc190cmFja2VkIjpmYWxzZSwidXVpZCI6IjdiZjJhOGI4MTc5YzRmMTViYWZmOGViYjg4N2RkOWZhMTcxNDQ4NDY0MDk5NzY1MjEzMiJ9LCJzaWduYXR1cmUiOiIifQ==","edge_media_to_tagged_user":{"edges":[]},"edge_media_to_caption":{"edges":[{"node":{"text":"Cuando se te pegan las mantas \ud83d\ude48\ud83d\ude48\ud83d\ude48\n.\n10,90\u20ac\n.\nhttp://s.click.aliexpress.com/e/EaEYFaE\n\nFACEBOOK.COM/ROPATEANDO\nBLOG.ROPATEANDO.COM\n.\n#mantabebe#ropateando #elarmarioderopateando #telegram #pic #picoftheday #outfit #outfitoftheday #outfitpost #ropa #instame #instalike #instalove #instalook #fashion #moda #instablogger #ootd #love #instagood #me #cute #like #influencer #beautiful #style #streetstyle"}}]},"caption_is_edited":true,"edge_media_to_comment":{"count":2,"page_info":{"has_next_page":false,"end_cursor":null},"edges":[{"node":{"id":"17850908371233214","text":"Link","created_at":1518602595,"owner":{"id":"55206905","profile_pic_url":"https://instagram.fhel3-1.fna.fbcdn.net/vp/0f2d694caef7809255bd21e18579ebf3/5B2176B2/t51.2885-19/s150x150/22802830_358422461266066_4296876623711436800_n.jpg","username":"lorenacuaja"}}},{"node":{"id":"17924024554016118","text":"Enviado","created_at":1518602616,"owner":{"id":"2096327952","profile_pic_url":"https://instagram.fhel3-1.fna.fbcdn.net/vp/b142448b7225a12c25a81c4e4f84a577/5B0BFE21/t51.2885-19/s150x150/11930847_519140961600089_515209800_a.jpg","username":"ropateando"}}}]},"comments_disabled":false,"taken_at_timestamp":1518602517,"edge_media_preview_like":{"count":19,"edges":[{"node":{"id":"330280392","profile_pic_url":"https://instagram.fhel3-1.fna.fbcdn.net/vp/ff423c2bc927ec317701338712461b28/5B246257/t51.2885-19/s150x150/26071831_1616366641789125_3093631880650555392_n.jpg","username":"vlimamart"}},{"node":{"id":"5979047553","profile_pic_url":"https://instagram.fhel3-1.fna.fbcdn.net/vp/f4d1635630b571fb16b2b1f1cf99fd8e/5B039B10/t51.2885-19/s150x150/21227380_116088969094159_5157150429842243584_a.jpg","username":"dochylos"}},{"node":{"id":"226729325","profile_pic_url":"https://instagram.fhel3-1.fna.fbcdn.net/vp/8f76c54bb62f45ec33fe5e8b0fa2b733/5B234418/t51.2885-19/11428696_136540733352298_2103764682_a.jpg","username":"elsagcallejo"}},{"node":{"id":"2958399052","profile_pic_url":"https://instagram.fhel3-1.fna.fbcdn.net/vp/2ca058e070ce56861ae48fbf2c8ea931/5B1D2C9B/t51.2885-19/s150x150/19429360_320564085053737_4974100564364230656_a.jpg","username":"suraj_sk2"}},{"node":{"id":"1375472655","profile_pic_url":"https://instagram.fhel3-1.fna.fbcdn.net/vp/a3fd8350cb45401d0ab50aad95ef427f/5B111BD7/t51.2885-19/s150x150/26151195_2090241727875639_7471255521614364672_n.jpg","username":"alandashenka"}},{"node":{"id":"265784569","profile_pic_url":"https://instagram.fhel3-1.fna.fbcdn.net/vp/4b062db4cbf5bb2a50fbbffe2d6109b9/5B253FE0/t51.2885-19/s150x150/25017909_2061467437421348_4184874695654375424_n.jpg","username":"themayorsstatement"}},{"node":{"id":"6883303908","profile_pic_url":"https://instagram.fhel3-1.fna.fbcdn.net/vp/b4577832af28080a9607edcb758799cc/5B1A8203/t51.2885-19/s150x150/25037105_1997130850508677_1213534002938380288_n.jpg","username":"real247fitness"}},{"node":{"id":"1476593644","profile_pic_url":"https://instagram.fhel3-1.fna.fbcdn.net/vp/69d2a696339d3e64a6d6449cd36d10b9/5B151E06/t51.2885-19/s150x150/12139598_1056916654326731_785215976_a.jpg","username":"bbstylemiami"}},{"node":{"id":"5373895103","profile_pic_url":"https://instagram.fhel3-1.fna.fbcdn.net/vp/e4d101a7b7823862ff5ea09b9ca64db0/5B1C6515/t51.2885-19/s150x150/18443920_1839735143016586_6944955834094845952_a.jpg","username":"iambrokool"}},{"node":{"id":"345451524","profile_pic_url":"https://instagram.fhel3-1.fna.fbcdn.net/vp/0b4a2bceb2eaa1efd841874df94367e0/5B0B0207/t51.2885-19/11821658_877787485604500_693329869_a.jpg","username":"pleasefashionofficial"}}]},"edge_media_to_sponsor_user":{"edges":[]},"location":null,"viewer_has_liked":false,"viewer_has_saved":false,"viewer_has_saved_to_collection":false,"owner":{"id":"2096327952","profile_pic_url":"https://instagram.fhel3-1.fna.fbcdn.net/vp/b142448b7225a12c25a81c4e4f84a577/5B0BFE21/t51.2885-19/s150x150/11930847_519140961600089_515209800_a.jpg","username":"ropateando","blocked_by_viewer":false,"followed_by_viewer":false,"full_name":"RopaTeando","has_blocked_viewer":false,"is_private":false,"is_unpublished":false,"is_verified":false,"requested_by_viewer":false},"is_ad":false,"edge_web_media_to_related_media":{"edges":[]}}}}a

As you see it contains pictures, title, user's info, user's mark, comments... and many other.

dasdachs
3#
dasdachs Reply to 2018-02-20 16:34:58Z

Based on your problem I would look at InstaPy. It has a simple API and it uses Selenium, a framework for browser automation, so you can avoid the API limits.

Install InstaPy:

$ git clone https://github.com/timgrossmann/InstaPy.git
$ cd InstaPy
$ pip install .
# or
$ python setup.py install

Create a script:

# scraper.py
from instapy import InstaPy

insta_username = ''
insta_password = ''

# if you want to run this script on a server,
# simply add nogui=True to the InstaPy() constructor
session = InstaPy(username=insta_username, password=insta_password)
session.login()

# set up all the settings
session.set_upper_follower_count(limit=2500)
session.set_do_comment(True, percentage=10)
session.set_comments(['aMEIzing!', 'So much fun!!', 'Nicey!'])
session.set_dont_include(['friend1', 'friend2', 'friend3'])
session.set_dont_like(['pizza', 'girl'])

# do the actual liking
session.like_by_tags(['natgeo', 'world'], amount=100)

# end the bot session
session.end()

Run the script:

$ python scraper.py

Media:

  • The author, Tim GroƟmann, wrote an article on Medium about it.
  • The author gave a talk at EuroPython2017
  • Talk Python to Me did a great show with the author.

If you don't feel comfortable working with Python, take a look at Puppeteer.

Puppeteer is a Node library which provides a high-level API to control headless Chrome or Chromium over the DevTools Protocol. It can also be configured to use full (non-headless) Chrome or Chromium.

Install Puppeteer:

npm i --save puppeteer

Create a script:

// scraper.js
const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('https://instagram.com');
  // Take a screen shot  
  await page.screenshot({path: 'example.png'});

  await browser.close();
})();

Run the script:

$ node scraper.js

If you want to login, follow this guide.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.306917 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO