siongui / instago

Download/access photos, videos, stories, story highlights, postlives, following and followers of Instagram
The Unlicense
104 stars 10 forks source link
downloader go golang gopherjs instagram web-scraping webscraping

================================================================================== Instagram Photo, Video, Story, Highlight, Postlive, Following, and Follower in Go_

.. image:: https://img.shields.io/badge/Language-Go-blue.svg :target: https://golang.org/

.. image:: https://godoc.org/github.com/siongui/instago?status.svg :target: https://godoc.org/github.com/siongui/instago

.. image:: https://api.travis-ci.org/siongui/instago.svg?branch=master :target: https://travis-ci.org/siongui/instago

.. image:: https://goreportcard.com/badge/github.com/siongui/instago :target: https://goreportcard.com/report/github.com/siongui/instago

.. image:: https://img.shields.io/badge/license-Unlicense-blue.svg :target: https://raw.githubusercontent.com/siongui/instago/master/UNLICENSE

.. image:: https://img.shields.io/badge/Status-Beta-brightgreen.svg

.. image:: https://img.shields.io/twitter/url/https/github.com/siongui/instago.svg?style=social :target: https://twitter.com/intent/tweet?text=Wow:&url=%5Bobject%20Object%5D

Get Instagram_ media (photos and videos), stories, story highlights, postlives, following and followers in Go.

This package only access Instagram private and public API:

Obtain Cookies ++++++++++++++

Use Chrome extension in this repo <crx-cookies>_ to get the cookies. Load the extension using Chrome extension developer mode. Log in to Instagram using Chrome. Click on the loaded extension button and save the content as auth.json. We will use it later to access Instagram API.

Terminology +++++++++++

Given the URL of the post as follows:

::

https://www.instagram.com/p/BfJzG64BZVY/

The code of the post is BfJzG64BZVY.

Usage +++++

This package instago only access the Instagram public and private API and get metadata from the API.

Install the package by go get:

.. code-block:: bash

$ go get -u github.com/siongui/instago

You can use the following methods without cookies

For the other methods which need cookies to access Instagram API, you must call NewInstagramApiManager_ first:

.. code-block:: go

import ( "github.com/siongui/instago" )

mgr := instago.NewInstagramApiManager("auth.json")

Then you can use mgr to get metadata from Instagram API. For example, you can get all post codes of the user instagram <https://www.instagram.com/instagram/>__ as follows:

.. code-block:: go

codes, err := mgr.GetAllPostCode("instagram") if err != nil { panic(err) }

for _, code := range codes { println("URL: https://www.instagram.com/p/%s/\n", code) }

For complete examples, see test files (files ends with _test.go). The following are some examples you may be interested in:

Tricks ++++++

Private API +++++++++++

UNLICENSE +++++++++

Released in public domain. See UNLICENSE_.

References ++++++++++

.. [1] GitHub - siongui/goiguserid: Get id of Instagram user in Go <https://github.com/siongui/goiguserid> .. [2] GitHub - siongui/goigstorylink: Get Links (URL) of Instagram Stories in Go <https://github.com/siongui/goigstorylink> .. [3] GitHub - siongui/goigfollow: Get Instagram following and followers in Go <https://github.com/siongui/goigfollow> .. [4] GitHub - siongui/goigstorydl: Download Instagram Stories in Go <https://github.com/siongui/goigstorydl> .. [5] GitHub - siongui/goigmedia: Get links of Instagram user media (photos and videos) in Go. <https://github.com/siongui/goigmedia> .. [6] JSON Formatter & Validator <https://jsonformatter.curiousconcept.com/>

.. _Go: https://golang.org/ .. _Instagram: https://www.instagram.com/ .. _Chrome Developer Tools: https://developer.chrome.com/devtools .. _SO answer: https://stackoverflow.com/a/44773079 .. _Obtain cookies: https://github.com/hoschiCZ/instastories-backup#obtain-cookies .. _instastories-backup: https://github.com/hoschiCZ/instastories-backup .. _EditThisCookie: https://www.google.com/search?q=EditThisCookie .. _cookie-txt-export: https://github.com/siongui/cookie-txt-export.go .. _UNLICENSE: http://unlicense.org/ .. _replay.py: https://github.com/ping/instagram_private_api_extensions/blob/master/instagram_private_api_extensions/replay.py .. _instagram_private_api_extensions: https://github.com/ping/instagram_private_api_extensions .. _NewInstagramApiManager: https://godoc.org/github.com/siongui/instago#NewInstagramApiManager .. _issue #2: https://github.com/siongui/instago/issues/2 .. _igdlcrx: https://github.com/siongui/igdlcrx .. _Downloader for Instagram™ + Direct Message: https://chrome.google.com/webstore/detail/downloader-for-instagram/olkpikmlhoaojbbmmpejnimiglejmboe