Major code cleanup
Remove many code duplications, merely by using more pythonic idioms. Use GraphQL more often. Better cope with errors: All requests can be retried; failed requests do not cause program termination; all error strings are repeated to the user at the end of execution. download_post() (formerly download_node()) does not repeat node metadata request (before this commit, this request was executed up to three times).
This commit is contained in:
parent
5d83a4ccf6
commit
58882f508e
16
README.rst
16
README.rst
@ -235,15 +235,13 @@ For example, to get a list of all followees and a list of all followers of a pro
|
|||||||
loader.interactive_login(USERNAME)
|
loader.interactive_login(USERNAME)
|
||||||
|
|
||||||
# Retrieve followees
|
# Retrieve followees
|
||||||
followees = loader.get_followees(PROFILE)
|
|
||||||
print(PROFILE + " follows these profiles:")
|
print(PROFILE + " follows these profiles:")
|
||||||
for f in followees:
|
for f in loader.get_followees(PROFILE):
|
||||||
print("\t%s\t%s" % (f['username'], f['full_name']))
|
print("\t%s\t%s" % (f['username'], f['full_name']))
|
||||||
|
|
||||||
# Retrieve followers
|
# Retrieve followers
|
||||||
followers = loader.get_followers(PROFILE)
|
|
||||||
print("Followers of " + PROFILE + ":")
|
print("Followers of " + PROFILE + ":")
|
||||||
for f in followers:
|
for f in loader.get_followers(PROFILE):
|
||||||
print("\t%s\t%s" % (f['username'], f['full_name']))
|
print("\t%s\t%s" % (f['username'], f['full_name']))
|
||||||
|
|
||||||
Then, you may download all pictures of all followees with
|
Then, you may download all pictures of all followees with
|
||||||
@ -252,7 +250,7 @@ Then, you may download all pictures of all followees with
|
|||||||
|
|
||||||
for f in followees:
|
for f in followees:
|
||||||
try:
|
try:
|
||||||
loader.download(f['username'])
|
loader.download_profile(f['username'])
|
||||||
except instaloader.NonfatalException:
|
except instaloader.NonfatalException:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -260,9 +258,11 @@ You could also download your last 20 liked pics with
|
|||||||
|
|
||||||
.. code:: python
|
.. code:: python
|
||||||
|
|
||||||
loader.download_feed_pics(max_count=20, fast_update=True,
|
loader.download_feed_posts(max_count=20, fast_update=True,
|
||||||
filter_func=lambda node:
|
filter_func=lambda node:
|
||||||
not node["likes"]["viewer_has_liked"] if "likes" in node else not node["viewer_has_liked"])
|
not node["likes"]["viewer_has_liked"]
|
||||||
|
if "likes" in node else
|
||||||
|
not node["viewer_has_liked"])
|
||||||
|
|
||||||
To download the last 20 pictures with hashtag #cat, do
|
To download the last 20 pictures with hashtag #cat, do
|
||||||
|
|
||||||
|
710
instaloader.py
710
instaloader.py
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user