Created
July 15, 2020 08:54
-
-
Save toshihiroryuu/023249f2789133de67b14a09267d90c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
------------------------------------------------------------------------------ | |
File name : insta_downloader.py | |
Description : Dowload all conetents from instagram | |
Python Version : 3.6.2 | |
Copyright : Open Source (MIT) | |
------------------------------------------------------------------------------ | |
Version Date Author Remarks | |
1.1 15-July-2020 Athul Mathew Created | |
------------------------------------------------------------------------------ | |
''' | |
from datetime import datetime | |
from itertools import dropwhile, takewhile | |
from instaloader import Instaloader | |
from instaloader import Profile | |
USERNAME = "*******" | |
PASSWORD = "*******" | |
# Get instance | |
L = Instaloader(download_video_thumbnails=False, | |
download_comments=False, | |
save_metadata=False, | |
compress_json=False, | |
max_connection_attempts=10) | |
# Optionally, login or load session | |
L.login(USERNAME, PASSWORD) | |
SINCE = datetime.today() | |
UNTIL = datetime(2018, 5, 1) | |
followers_list = [] | |
profile = Profile.from_username(L.context, USERNAME) | |
for follower in profile.get_followees(): | |
followers_list.append(follower.username) | |
profile = Profile.from_username(L.context, follower.username) | |
print("--------------------------", follower.username, "--------------------------")\ | |
posts = Profile.from_username(L.context, follower.username).get_posts() | |
for post in takewhile(lambda p: p.date > UNTIL, dropwhile(lambda p: p.date > SINCE, posts)): | |
# print(follower.username, " : ", post.date) | |
L.download_post(post, target = profile.username) | |
print("--------------------------", profile.username, ": complete", "-------------") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Edit username and password @ line 15, 16
Change Since and Until dates @ line 31, 32.