2016-09-19 19:45:15 +02:00
|
|
|
Instaloader
|
|
|
|
===========
|
|
|
|
|
2017-04-22 11:58:59 +02:00
|
|
|
Tool to automatically download pictures (or videos) of given profiles
|
|
|
|
from Instagram.
|
2016-09-19 19:45:15 +02:00
|
|
|
|
2016-09-22 19:02:26 +02:00
|
|
|
Installation
|
|
|
|
------------
|
2016-09-19 19:45:15 +02:00
|
|
|
|
2017-02-13 10:03:34 +01:00
|
|
|
Instaloader is written in Python, thus ensure having
|
2017-02-13 09:57:03 +01:00
|
|
|
`Python <https://www.python.org/>`__ (at least version 3.5) installed.
|
2016-09-19 19:45:15 +02:00
|
|
|
|
2016-09-22 19:02:26 +02:00
|
|
|
If you intend to use this tool under Windows, it is recommended
|
|
|
|
to install
|
2016-09-19 19:45:15 +02:00
|
|
|
`win-unicode-console <https://pypi.python.org/pypi/win_unicode_console>`__.
|
|
|
|
|
|
|
|
If you have `pip <https://pypi.python.org/pypi/pip>`__ installed, you
|
2017-02-13 10:03:34 +01:00
|
|
|
may install Instaloader using
|
2016-09-19 19:45:15 +02:00
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
pip3 install instaloader
|
|
|
|
|
2017-03-19 14:40:51 +01:00
|
|
|
Alternatively, to get the most current version of Instaloader from our
|
|
|
|
`Git repository <https://github.com/Thammus/instaloader>`__:
|
2016-09-19 19:45:15 +02:00
|
|
|
|
|
|
|
::
|
|
|
|
|
2017-03-19 14:40:51 +01:00
|
|
|
pip3 install git+https://github.com/Thammus/instaloader
|
2016-09-19 19:45:15 +02:00
|
|
|
|
2017-04-22 11:58:59 +02:00
|
|
|
(pass ``--upgrade`` to upgrade if Instaloader is already installed)
|
|
|
|
|
2017-02-13 10:03:34 +01:00
|
|
|
Instaloader requires
|
2016-09-22 19:02:26 +02:00
|
|
|
`requests <https://pypi.python.org/pypi/requests>`__, which
|
2017-03-19 14:40:51 +01:00
|
|
|
will be installed automatically, if it is not already installed.
|
2016-09-19 19:45:15 +02:00
|
|
|
|
2016-09-22 19:02:26 +02:00
|
|
|
How to automatically download pictures from Instagram
|
|
|
|
-----------------------------------------------------
|
|
|
|
|
2017-04-22 11:58:59 +02:00
|
|
|
To **download all pictures and videos of a profile**, as well as the
|
|
|
|
**profile picture**, do
|
2016-09-19 19:45:15 +02:00
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
instaloader profile [profile ...]
|
|
|
|
|
|
|
|
where ``profile`` is the name of a profile you want to download. Instead
|
|
|
|
of only one profile, you may also specify a list of profiles.
|
|
|
|
|
2017-04-22 12:11:56 +02:00
|
|
|
To later **update your local copy** of that profiles, you may run
|
2016-09-19 19:45:15 +02:00
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
instaloader --fast-update profile [profile ...]
|
|
|
|
|
2017-04-22 11:58:59 +02:00
|
|
|
When ``--fast-update`` is given, Instaloader stops when arriving at
|
2016-09-19 19:45:15 +02:00
|
|
|
the first already-downloaded picture.
|
|
|
|
|
|
|
|
Instaloader can also be used to **download private profiles**. To do so,
|
|
|
|
invoke it with
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
instaloader --login=your_username profile [profile ...]
|
|
|
|
|
|
|
|
When invoked like this, it also **stores the session cookies** in a file
|
2017-04-22 11:58:59 +02:00
|
|
|
in your temporary directory, which will be reused later when ``--login`` is given. So
|
2016-09-19 19:45:15 +02:00
|
|
|
you can download private profiles **non-interactively** when you already
|
2016-09-22 19:02:26 +02:00
|
|
|
have a valid session cookie file.
|
2016-09-19 19:45:15 +02:00
|
|
|
|
2017-04-22 12:11:56 +02:00
|
|
|
You may also download
|
2017-04-22 11:58:59 +02:00
|
|
|
**the most recent pictures by hashtag**:
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
instaloader "#hashtag"
|
|
|
|
|
2016-09-19 19:45:15 +02:00
|
|
|
If you want to **download all followees of a given profile**, call
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
instaloader --login=your_username @profile
|
|
|
|
|
2016-09-22 19:02:26 +02:00
|
|
|
To **download all the pictures from your feed which you have liked**, call
|
2016-09-19 19:45:15 +02:00
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
instaloader --login=your_username :feed-liked
|
|
|
|
|
2017-04-22 11:58:59 +02:00
|
|
|
or to **download all pictures from your feed**:
|
2016-09-19 19:45:15 +02:00
|
|
|
|
2017-04-22 11:58:59 +02:00
|
|
|
::
|
|
|
|
|
|
|
|
instaloader --login=your_username :feed-all
|
2016-09-19 19:45:15 +02:00
|
|
|
|
2017-04-22 11:58:59 +02:00
|
|
|
Advanced Options
|
2016-09-19 19:45:15 +02:00
|
|
|
----------------
|
|
|
|
|
2017-04-22 11:58:59 +02:00
|
|
|
The following flags can be given to Instaloader to specify how profiles should
|
|
|
|
be downloaded.
|
|
|
|
|
|
|
|
--fast-update Stop when encountering the first already-downloaded post
|
|
|
|
of a profile.
|
2017-04-22 12:11:56 +02:00
|
|
|
--profile-pic-only Only download profile pictures. Without this flag, the current
|
2017-04-22 11:58:59 +02:00
|
|
|
profile picture and all the profile's posts are downloaded.
|
|
|
|
--skip-videos Skip posts which are videos.
|
|
|
|
--geotags Also **download geotags** and store Google Maps links in
|
|
|
|
separate textfiles.
|
2017-04-22 17:21:02 +02:00
|
|
|
--count COUNT If used with ``#hashtag``, ``:feed-all`` or
|
2017-04-22 17:34:49 +02:00
|
|
|
``:feed-liked``: Do not attempt to download more than COUNT
|
|
|
|
posts.
|
2017-04-22 11:58:59 +02:00
|
|
|
--quiet Do not output any messages except warnings and errors. This
|
|
|
|
option makes Instaloader **suitable as a cron job**.
|
|
|
|
--no-sleep Normally, Instaloader waits a few seconds between requests
|
|
|
|
to the Instagram servers. This flag inhibits this behavior.
|
|
|
|
--password PASSWORD If used with ``--login``, use parameter as password if no
|
|
|
|
valid session file is found, instead of asking
|
|
|
|
interactively.
|
|
|
|
--sessionfile FILE Specify an alternative place for loading and storing the
|
2017-04-22 12:11:56 +02:00
|
|
|
session cookies. Without this flag, they are stored in a path
|
2017-04-22 11:58:59 +02:00
|
|
|
within your temporary directory, encoding your local
|
|
|
|
username and your instagram profile name.
|
2017-06-25 14:53:43 +02:00
|
|
|
--no-profile-subdir Instead of creating a subdirectory for each profile and
|
|
|
|
storing pictures there, store pictures in files named
|
2017-06-27 09:17:06 +02:00
|
|
|
'PROFILE__DATE_TIME.jpg.'
|
|
|
|
--hashtag-username When downloading by #hashtag, lookup the picture's username
|
|
|
|
to decide in which directory to store, rather than storing
|
|
|
|
all pictures in directory '#hashtag'.
|
2017-04-22 11:58:59 +02:00
|
|
|
|
|
|
|
To get a list of all flags, run ``instaloader --help``.
|
|
|
|
|
|
|
|
Usage as Python module
|
|
|
|
----------------------
|
|
|
|
|
2017-02-13 10:03:34 +01:00
|
|
|
You may also use parts of Instaloader as library to do other interesting
|
2016-09-19 19:45:15 +02:00
|
|
|
things.
|
|
|
|
|
2017-04-22 11:58:59 +02:00
|
|
|
For example, to get a list of all followees of a profile as well as
|
2016-09-19 19:45:15 +02:00
|
|
|
their follower count, do
|
|
|
|
|
|
|
|
.. code:: python
|
|
|
|
|
|
|
|
import instaloader
|
|
|
|
|
2017-06-24 22:43:40 +02:00
|
|
|
# Get instance
|
|
|
|
loader = instaloader.Instaloader()
|
2016-09-19 19:45:15 +02:00
|
|
|
|
2017-06-24 22:43:40 +02:00
|
|
|
# Login
|
|
|
|
loader.interactive_login(USERNAME)
|
|
|
|
|
|
|
|
# Retrieve followees
|
|
|
|
followees = loader.get_followees(PROFILE)
|
2016-09-19 19:45:15 +02:00
|
|
|
for f in followees:
|
|
|
|
print("%i\t%s\t%s" % (f['follower_count'], f['username'], f['full_name']))
|
|
|
|
|
|
|
|
Then, you may download all pictures of all followees with
|
|
|
|
|
|
|
|
.. code:: python
|
|
|
|
|
|
|
|
for f in followees:
|
|
|
|
try:
|
2017-06-24 22:43:40 +02:00
|
|
|
loader.download(f['username'])
|
2016-09-19 19:45:15 +02:00
|
|
|
except instaloader.NonfatalException:
|
|
|
|
pass
|
|
|
|
|
|
|
|
You could also download your last 20 liked pics with
|
|
|
|
|
|
|
|
.. code:: python
|
|
|
|
|
2017-06-24 22:43:40 +02:00
|
|
|
oader.download_feed_pics(max_count=20, fast_update=True,
|
|
|
|
filter_func=lambda node:
|
2017-04-21 18:01:20 +02:00
|
|
|
not node["likes"]["viewer_has_liked"] if "likes" in node else not node["viewer_has_liked"])
|
2016-09-19 19:45:15 +02:00
|
|
|
|
2017-04-17 12:10:43 +02:00
|
|
|
To download the last 20 pictures with hashtag #cat, do
|
|
|
|
|
|
|
|
.. code:: python
|
|
|
|
|
2017-06-24 22:43:40 +02:00
|
|
|
loader.download_hashtag('cat', max_count=20)
|
2017-04-17 12:10:43 +02:00
|
|
|
|
2016-09-19 19:45:15 +02:00
|
|
|
Each Instagram profile has its own unique ID which stays unmodified even
|
|
|
|
if a user changes his/her username. To get said ID, given the profile's
|
|
|
|
name, you may call
|
|
|
|
|
|
|
|
.. code:: python
|
|
|
|
|
2017-06-24 22:43:40 +02:00
|
|
|
loader.get_id_by_username(PROFILE_NAME)
|
2016-09-19 19:45:15 +02:00
|
|
|
|
|
|
|
``get_followees()`` also returns unique IDs for all loaded followees. To
|
|
|
|
get the current username of a profile, given this unique ID
|
|
|
|
``get_username_by_id()`` can be used. For example:
|
|
|
|
|
|
|
|
.. code:: python
|
|
|
|
|
2017-06-24 22:43:40 +02:00
|
|
|
loader.get_username_by_id(followees[0]['id'])
|