2017-12-03 17:20:51 +03:00
|
|
|
.. meta::
|
|
|
|
:description:
|
2018-03-22 18:07:19 +03:00
|
|
|
Documentation of Instaloader module, a powerful and easy-to-use
|
|
|
|
Python library to download Instagram media and metadata.
|
2017-12-03 17:20:51 +03:00
|
|
|
|
2017-09-08 11:35:38 +03:00
|
|
|
Python Module :mod:`instaloader`
|
|
|
|
--------------------------------
|
2017-08-25 17:54:36 +03:00
|
|
|
|
2017-09-08 11:35:38 +03:00
|
|
|
.. module:: instaloader
|
2017-08-25 17:54:36 +03:00
|
|
|
|
2017-09-08 11:35:38 +03:00
|
|
|
.. highlight:: python
|
|
|
|
|
2018-04-20 17:36:37 +03:00
|
|
|
.. contents::
|
|
|
|
:backlinks: none
|
|
|
|
|
2017-11-14 13:18:30 +03:00
|
|
|
Instaloader exposes its internally used methods as a Python module, making it a
|
|
|
|
**powerful and easy-to-use Python API for Instagram**, allowing to further
|
|
|
|
customize obtaining media and metadata.
|
2017-09-08 11:35:38 +03:00
|
|
|
|
2017-11-14 13:18:30 +03:00
|
|
|
Start with getting an instance of :class:`Instaloader`::
|
2017-09-08 11:35:38 +03:00
|
|
|
|
|
|
|
import instaloader
|
|
|
|
|
|
|
|
# Get instance
|
2017-11-14 13:18:30 +03:00
|
|
|
L = instaloader.Instaloader()
|
|
|
|
|
|
|
|
# Optionally, login or load session
|
|
|
|
L.login(USER, PASSWORD) # (login)
|
|
|
|
L.interactive_login(USER) # (ask password on terminal)
|
|
|
|
L.load_session_from_file(USER) # (load session created w/
|
|
|
|
# `instaloader -l USERNAME`)
|
|
|
|
|
|
|
|
:mod:`instaloader` provides the :class:`Post` structure, which represents a
|
|
|
|
picture, video or sidecar (set of multiple pictures/videos) posted in a user's
|
|
|
|
profile. :class:`Instaloader` provides methods to iterate over Posts from a
|
|
|
|
certain source::
|
|
|
|
|
|
|
|
for post in L.get_hashtag_posts('cat'):
|
|
|
|
# post is an instance of instaloader.Post
|
|
|
|
L.download_post(post, target='#cat')
|
2017-09-08 11:35:38 +03:00
|
|
|
|
2017-11-14 13:18:30 +03:00
|
|
|
Besides :func:`Instaloader.get_hashtag_posts`, there is
|
2018-03-18 18:31:32 +03:00
|
|
|
:func:`Instaloader.get_feed_posts`, :func:`Profile.get_posts` and
|
|
|
|
:func:`Profile.get_saved_posts`.
|
2017-11-14 13:18:30 +03:00
|
|
|
Also, :class:`Post` instances can be created with :func:`Post.from_shortcode`
|
|
|
|
and :func:`Post.from_mediaid`.
|
|
|
|
|
|
|
|
A reference of the many methods provided by the :mod:`instaloader` module is
|
2018-04-20 17:36:37 +03:00
|
|
|
provided in the remainder of this document.
|
2017-08-25 17:54:36 +03:00
|
|
|
|
|
|
|
``Instaloader`` (Main Class)
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
2017-09-08 11:35:38 +03:00
|
|
|
.. autoclass:: Instaloader
|
|
|
|
:no-show-inheritance:
|
2017-08-29 12:03:12 +03:00
|
|
|
|
2018-04-20 17:36:37 +03:00
|
|
|
Instagram Structures
|
|
|
|
^^^^^^^^^^^^^^^^^^^^
|
2018-03-18 18:31:32 +03:00
|
|
|
|
2018-04-20 17:36:37 +03:00
|
|
|
.. autofunction:: load_structure_from_file
|
2018-03-18 18:31:32 +03:00
|
|
|
|
2018-04-20 17:36:37 +03:00
|
|
|
.. autofunction:: save_structure_to_file
|
|
|
|
|
|
|
|
``Post``
|
|
|
|
""""""""
|
|
|
|
|
|
|
|
.. autofunction:: mediaid_to_shortcode
|
|
|
|
|
|
|
|
.. autofunction:: shortcode_to_mediaid
|
2017-08-25 17:54:36 +03:00
|
|
|
|
2017-09-08 11:35:38 +03:00
|
|
|
.. autoclass:: Post
|
|
|
|
:no-show-inheritance:
|
|
|
|
|
2018-04-20 17:36:37 +03:00
|
|
|
``StoryItem``
|
|
|
|
"""""""""""""
|
2017-09-08 11:35:38 +03:00
|
|
|
|
2018-04-20 17:36:37 +03:00
|
|
|
.. autoclass:: StoryItem
|
|
|
|
:no-show-inheritance:
|
2017-09-08 11:35:38 +03:00
|
|
|
|
2018-04-20 17:36:37 +03:00
|
|
|
``Profile``
|
|
|
|
"""""""""""
|
|
|
|
|
|
|
|
.. autoclass:: Profile
|
|
|
|
:no-show-inheritance:
|
2017-09-08 11:35:38 +03:00
|
|
|
|
|
|
|
Exceptions
|
|
|
|
^^^^^^^^^^
|
|
|
|
|
|
|
|
.. autoexception:: InstaloaderException
|
|
|
|
:no-show-inheritance:
|
|
|
|
|
2018-04-20 17:36:37 +03:00
|
|
|
.. autoexception:: QueryReturnedBadRequestException
|
|
|
|
|
2017-09-08 11:35:38 +03:00
|
|
|
.. autoexception:: QueryReturnedNotFoundException
|
|
|
|
|
2018-03-18 18:29:34 +03:00
|
|
|
.. autoexception:: QueryReturnedForbiddenException
|
|
|
|
|
2017-09-08 11:35:38 +03:00
|
|
|
.. autoexception:: ProfileNotExistsException
|
|
|
|
|
|
|
|
.. autoexception:: ProfileHasNoPicsException
|
|
|
|
|
|
|
|
.. autoexception:: PrivateProfileNotFollowedException
|
|
|
|
|
|
|
|
.. autoexception:: LoginRequiredException
|
|
|
|
|
|
|
|
.. autoexception:: InvalidArgumentException
|
|
|
|
|
|
|
|
.. autoexception:: BadResponseException
|
|
|
|
|
|
|
|
.. autoexception:: BadCredentialsException
|
|
|
|
|
|
|
|
.. autoexception:: ConnectionException
|
2018-03-18 18:29:34 +03:00
|
|
|
|
|
|
|
.. autoexception:: TooManyRequestsException
|
2018-04-20 17:36:37 +03:00
|
|
|
|
|
|
|
``InstaloaderContext`` (Low-level functions)
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
.. autoclass:: InstaloaderContext
|
|
|
|
:no-show-inheritance:
|