Download Posts in a Specific Period
To only download Instagram pictures (and metadata) that are within a specific
period, you can simply use :func:`~itertools.dropwhile` and
:func:`~itertools.takewhile` from :mod:`itertools` on a generator that returns
Posts in exact chronological order, such as :meth:`Profile.get_posts`.
System Message: INFO/1 (<string>, line 30)
No role entry for "func" in module "docutils.parsers.rst.languages.en".
Trying "func" as canonical role name.
System Message: ERROR/3 (<string>, line 30); backlink
Unknown interpreted text role "func".
System Message: INFO/1 (<string>, line 30)
No role entry for "func" in module "docutils.parsers.rst.languages.en".
Trying "func" as canonical role name.
System Message: ERROR/3 (<string>, line 30); backlink
Unknown interpreted text role "func".
System Message: INFO/1 (<string>, line 30)
No role entry for "mod" in module "docutils.parsers.rst.languages.en".
Trying "mod" as canonical role name.
System Message: ERROR/3 (<string>, line 30); backlink
Unknown interpreted text role "mod".
System Message: INFO/1 (<string>, line 30)
No role entry for "meth" in module "docutils.parsers.rst.languages.en".
Trying "meth" as canonical role name.
System Message: ERROR/3 (<string>, line 30); backlink
Unknown interpreted text role "meth".
System Message: INFO/1 (<string>, line 35)
No directive entry for "literalinclude" in module "docutils.parsers.rst.languages.en".
Trying "literalinclude" as canonical directive name.
System Message: ERROR/3 (<string>, line 35)
Unknown directive type "literalinclude".
.. literalinclude:: codesnippets/121_since_until.py
See also :class:`Post`, :meth:`Instaloader.download_post`.
System Message: INFO/1 (<string>, line 37)
No role entry for "class" in module "docutils.parsers.rst.languages.en".
Trying "class" as canonical role name.
System Message: ERROR/3 (<string>, line 37); backlink
Unknown interpreted text role "class".
System Message: INFO/1 (<string>, line 37)
No role entry for "meth" in module "docutils.parsers.rst.languages.en".
Trying "meth" as canonical role name.
System Message: ERROR/3 (<string>, line 37); backlink
Unknown interpreted text role "meth".
Discussed in :issue:`121`.
System Message: INFO/1 (<string>, line 39)
No role entry for "issue" in module "docutils.parsers.rst.languages.en".
Trying "issue" as canonical role name.
System Message: ERROR/3 (<string>, line 39); backlink
Unknown interpreted text role "issue".
The code example with :func:`~itertools.dropwhile` and
:func:`~itertools.takewhile` makes the assumption that the post iterator returns
posts in exact chronological order. As discussed in :issue:`666`, the following
approach fits for an almost chronological order, where up to k older posts
are inserted into an otherwise chronological order, such as an Hashtag feed.
System Message: INFO/1 (<string>, line 41)
No role entry for "func" in module "docutils.parsers.rst.languages.en".
Trying "func" as canonical role name.
System Message: ERROR/3 (<string>, line 41); backlink
Unknown interpreted text role "func".
System Message: INFO/1 (<string>, line 41)
No role entry for "func" in module "docutils.parsers.rst.languages.en".
Trying "func" as canonical role name.
System Message: ERROR/3 (<string>, line 41); backlink
Unknown interpreted text role "func".
System Message: INFO/1 (<string>, line 41)
No role entry for "issue" in module "docutils.parsers.rst.languages.en".
Trying "issue" as canonical role name.
System Message: ERROR/3 (<string>, line 41); backlink
Unknown interpreted text role "issue".
System Message: INFO/1 (<string>, line 47)
No directive entry for "literalinclude" in module "docutils.parsers.rst.languages.en".
Trying "literalinclude" as canonical directive name.
System Message: ERROR/3 (<string>, line 47)
Unknown directive type "literalinclude".
.. literalinclude:: codesnippets/666_historical_hashtag_data.py
Likes of a Profile / Ghost Followers
To obtain a list of your inactive followers, i.e. followers that did not like
any of your pictures, into a file you can use this approach.
System Message: INFO/1 (<string>, line 55)
No directive entry for "literalinclude" in module "docutils.parsers.rst.languages.en".
Trying "literalinclude" as canonical directive name.
System Message: ERROR/3 (<string>, line 55)
Unknown directive type "literalinclude".
.. literalinclude:: codesnippets/120_ghost_followers.py
See also :meth:`Profile.get_posts`, :meth:`Post.get_likes`,
:meth:`Profile.get_followers`, :meth:`Instaloader.load_session_from_file`,
:meth:`Profile.from_username`.
System Message: INFO/1 (<string>, line 57)
No role entry for "meth" in module "docutils.parsers.rst.languages.en".
Trying "meth" as canonical role name.
System Message: ERROR/3 (<string>, line 57); backlink
Unknown interpreted text role "meth".
System Message: INFO/1 (<string>, line 57)
No role entry for "meth" in module "docutils.parsers.rst.languages.en".
Trying "meth" as canonical role name.
System Message: ERROR/3 (<string>, line 57); backlink
Unknown interpreted text role "meth".
System Message: INFO/1 (<string>, line 57)
No role entry for "meth" in module "docutils.parsers.rst.languages.en".
Trying "meth" as canonical role name.
System Message: ERROR/3 (<string>, line 57); backlink
Unknown interpreted text role "meth".
System Message: INFO/1 (<string>, line 57)
No role entry for "meth" in module "docutils.parsers.rst.languages.en".
Trying "meth" as canonical role name.
System Message: ERROR/3 (<string>, line 57); backlink
Unknown interpreted text role "meth".
System Message: INFO/1 (<string>, line 57)
No role entry for "meth" in module "docutils.parsers.rst.languages.en".
Trying "meth" as canonical role name.
System Message: ERROR/3 (<string>, line 57); backlink
Unknown interpreted text role "meth".
Discussed in :issue:`120`.
System Message: INFO/1 (<string>, line 61)
No role entry for "issue" in module "docutils.parsers.rst.languages.en".
Trying "issue" as canonical role name.
System Message: ERROR/3 (<string>, line 61); backlink
Unknown interpreted text role "issue".
Track Deleted Posts
This script uses Instaloader to obtain a list of currently-online Instagram and
compares it with the set of posts that you already have downloaded. It outputs
a list of posts which are online but not offline (i.e. not yet downloaded) and a
list of posts which are offline but not online (i.e. deleted in the profile).
System Message: INFO/1 (<string>, line 71)
No directive entry for "literalinclude" in module "docutils.parsers.rst.languages.en".
Trying "literalinclude" as canonical directive name.
System Message: ERROR/3 (<string>, line 71)
Unknown directive type "literalinclude".
.. literalinclude:: codesnippets/56_track_deleted.py
See also :func:`load_structure_from_file`, :meth:`Profile.from_username`,
:meth:`Profile.get_posts`, :class:`Post`.
System Message: INFO/1 (<string>, line 73)
No role entry for "func" in module "docutils.parsers.rst.languages.en".
Trying "func" as canonical role name.
System Message: ERROR/3 (<string>, line 73); backlink
Unknown interpreted text role "func".
System Message: INFO/1 (<string>, line 73)
No role entry for "meth" in module "docutils.parsers.rst.languages.en".
Trying "meth" as canonical role name.
System Message: ERROR/3 (<string>, line 73); backlink
Unknown interpreted text role "meth".
System Message: INFO/1 (<string>, line 73)
No role entry for "meth" in module "docutils.parsers.rst.languages.en".
Trying "meth" as canonical role name.
System Message: ERROR/3 (<string>, line 73); backlink
Unknown interpreted text role "meth".
System Message: INFO/1 (<string>, line 73)
No role entry for "class" in module "docutils.parsers.rst.languages.en".
Trying "class" as canonical role name.
System Message: ERROR/3 (<string>, line 73); backlink
Unknown interpreted text role "class".
Discussed in :issue:`56`.
System Message: INFO/1 (<string>, line 76)
No role entry for "issue" in module "docutils.parsers.rst.languages.en".
Trying "issue" as canonical role name.
System Message: ERROR/3 (<string>, line 76); backlink
Unknown interpreted text role "issue".
Only one Post per User
To download only the one most recent post from each user, this snippet creates a
:class:`set` that contains the users of which a post has already been
downloaded. While iterating the posts, it checks whether the post's owner
already is in the set. If not, the post is downloaded from Instagram and the
user is added to that set.
System Message: INFO/1 (<string>, line 81)
No role entry for "class" in module "docutils.parsers.rst.languages.en".
Trying "class" as canonical role name.
System Message: ERROR/3 (<string>, line 81); backlink
Unknown interpreted text role "class".
System Message: INFO/1 (<string>, line 87)
No directive entry for "literalinclude" in module "docutils.parsers.rst.languages.en".
Trying "literalinclude" as canonical directive name.
System Message: ERROR/3 (<string>, line 87)
Unknown directive type "literalinclude".
.. literalinclude:: codesnippets/113_only_one_per_user.py
See also :class:`Post`, :meth:`Instaloader.download_post`,
:attr:`Post.owner_profile`, :class:`Profile`.
System Message: INFO/1 (<string>, line 89)
No role entry for "class" in module "docutils.parsers.rst.languages.en".
Trying "class" as canonical role name.
System Message: ERROR/3 (<string>, line 89); backlink
Unknown interpreted text role "class".
System Message: INFO/1 (<string>, line 89)
No role entry for "meth" in module "docutils.parsers.rst.languages.en".
Trying "meth" as canonical role name.
System Message: ERROR/3 (<string>, line 89); backlink
Unknown interpreted text role "meth".
System Message: INFO/1 (<string>, line 89)
No role entry for "attr" in module "docutils.parsers.rst.languages.en".
Trying "attr" as canonical role name.
System Message: ERROR/3 (<string>, line 89); backlink
Unknown interpreted text role "attr".
System Message: INFO/1 (<string>, line 89)
No role entry for "class" in module "docutils.parsers.rst.languages.en".
Trying "class" as canonical role name.
System Message: ERROR/3 (<string>, line 89); backlink
Unknown interpreted text role "class".
Discussed in :issue:`113`.
System Message: INFO/1 (<string>, line 92)
No role entry for "issue" in module "docutils.parsers.rst.languages.en".
Trying "issue" as canonical role name.
System Message: ERROR/3 (<string>, line 92); backlink
Unknown interpreted text role "issue".
Top X Posts of User
With Instaloader, it is easy to download the few most-liked pictres of a user.
System Message: INFO/1 (<string>, line 99)
No directive entry for "literalinclude" in module "docutils.parsers.rst.languages.en".
Trying "literalinclude" as canonical directive name.
System Message: ERROR/3 (<string>, line 99)
Unknown directive type "literalinclude".
.. literalinclude:: codesnippets/194_top_x_of_user.py
Discussed in :issue:`194`.
System Message: INFO/1 (<string>, line 101)
No role entry for "issue" in module "docutils.parsers.rst.languages.en".
Trying "issue" as canonical role name.
System Message: ERROR/3 (<string>, line 101); backlink
Unknown interpreted text role "issue".
Add Captions to Images
Instaloader does not modify the downloaded JPEG file. However, one could combine
it with an imaging library such as Pillow or PIL to render the caption on
Instagram pictures. The following shows an approach.
System Message: INFO/1 (<string>, line 121)
No directive entry for "literalinclude" in module "docutils.parsers.rst.languages.en".
Trying "literalinclude" as canonical directive name.
System Message: ERROR/3 (<string>, line 121)
Unknown directive type "literalinclude".
.. literalinclude:: codesnippets/110_pil_captions.py
See also :attr:`Post.caption`, :attr:`Post.url`, :meth:`Post.from_shortcode`,
:func:`load_structure_from_file`.
System Message: INFO/1 (<string>, line 123)
No role entry for "attr" in module "docutils.parsers.rst.languages.en".
Trying "attr" as canonical role name.
System Message: ERROR/3 (<string>, line 123); backlink
Unknown interpreted text role "attr".
System Message: INFO/1 (<string>, line 123)
No role entry for "attr" in module "docutils.parsers.rst.languages.en".
Trying "attr" as canonical role name.
System Message: ERROR/3 (<string>, line 123); backlink
Unknown interpreted text role "attr".
System Message: INFO/1 (<string>, line 123)
No role entry for "meth" in module "docutils.parsers.rst.languages.en".
Trying "meth" as canonical role name.
System Message: ERROR/3 (<string>, line 123); backlink
Unknown interpreted text role "meth".
System Message: INFO/1 (<string>, line 123)
No role entry for "func" in module "docutils.parsers.rst.languages.en".
Trying "func" as canonical role name.
System Message: ERROR/3 (<string>, line 123); backlink
Unknown interpreted text role "func".
Discussed in :issue:`110`.
System Message: INFO/1 (<string>, line 126)
No role entry for "issue" in module "docutils.parsers.rst.languages.en".
Trying "issue" as canonical role name.
System Message: ERROR/3 (<string>, line 126); backlink
Unknown interpreted text role "issue".