Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/siongui/instago

Download/access photos, videos, stories, story highlights, postlives, following and followers of Instagram
https://github.com/siongui/instago

downloader go golang gopherjs instagram web-scraping webscraping

Last synced: 24 days ago
JSON representation

Download/access photos, videos, stories, story highlights, postlives, following and followers of Instagram

Lists

README

        

==================================================================================
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:

- Based on this package, Chrome extension igdlcrx_ helps you download stories
and posts, similiar to `Downloader for Instagram™ + Direct Message`_

- Also based on this package, the package in `download `_ directory
helps you download media (photos/videos), stories, story highlights, or
postlives.

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

Use `Chrome extension in this repo `_ 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

- `GetUserInfoNoLogin `_
- `GetRecentPostCodeNoLogin `_
- `GetUserId `_
- `GetPostInfoNoLogin `_
- `GetUserProfilePicUrlHd `_
- `GetAllPostMediaNoLogin `_

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 `__ 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:

- Get post information: See `post_test.go `_
- Get URLs of all posts of a specific user: See `getall_test.go `_
- Get id by username: See `userinfo_test.go `_
- Discover top live: See `toplive_test.go `_
- Top searches of Instagram web: See `topsearch_test.go `_

Tricks
++++++

- Use the following User-Agent to get post-live field in reels tray feed.

**Instagram 10.26.0 (iPhone8,1; iOS 10_2; en_US; en-US; scale=2.00; gamut=normal; 750x1334) AppleWebKit/420+**

From `replay.py`_ in `instagram_private_api_extensions`_

- Get all user's media:

* `How can I get a user's media from Instagram without authenticating as a user? - Stack Overflow `_
* `instagram_web_api.client — instagram_private_api 1.4.1 documentation `_
* `instagram graphql api id - Google search `_

- `Web scraping: instagram.com | Shiori `_

- | `query_hash on instagram graphql - Google search `_
| `How to scrape pages with infinite scroll: extracting data from Instagram - Diggernaut `_
| `colly instagram example `_

- Do not remove query string in the URLs of photo/viedo/story/highlight. It may
cause 403 Forbidden when downloading the URL. See `issue #2`_ for more info.

- Saved endpoint: see `ping/instagram_private_api `_

- postlive URL issue: Google search "Bad URL timestamp". See `Instagram reports "Bad URL timestamp" `_. replacing & with & in the access link.

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

- `Get data from Instagram's private API — Alberto Moral `_
- `What is the API Endpoints for the Feeds "People who liked my posts" and "Activities from my followings" · Issue #42 · huttarichard/instagram-private-api · GitHub `_
- `Search · go instagram · GitHub `_
then found `Update timeline API from Get to Post `_
- `private API reference - github.com/ping/instagram_private_api `_

UNLICENSE
+++++++++

Released in public domain. See UNLICENSE_.

References
++++++++++

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

.. _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