Download with Instaloader and Python

1.7k views Asked by At

Sorry for my English. I use the Instaloader-Master to download instagram profiles. Until now, I used downloading through the command line, but I decided to switch to download through Python, because of the ability to bypass the blocking of the account, etc. Is my code set correctly for downloading the entire contents of the profile? And how to enable RateController?

import instaloader

USERNAME = 'ACCOUNT_NAME'
PASSWORD = 'PASSWORD'

SESSION_FILENAME = 'SESSION'

PROFILE = "nurgularikan.tr"
DIR = "{target}"
Name = "{date:%Y-%m-%d %H-%M-%S} {mediaid}_{owner_id}"
L = instaloader.Instaloader(dirname_pattern=DIR, filename_pattern=Name)
#L.login(USERNAME, PASSWORD)
L.load_session_from_file(username=USERNAME, filename=SESSION_FILENAME)
print('LOGIN.')

profile = instaloader.Profile.from_username(L.context, PROFILE)

for post in profile.get_posts():
    L.download_post(post, target=profile.username)
    filename = profile.username + '/' + L.format_filename(post, target=profile.username)
1

There are 1 answers

0
forsythe On

you can use this code to download profiles easily.

import instaloader
from instaloader import Profile, Post
import getpass

instance = instaloader.Instaloader()

def download_profile():
    user_name = str(input("enter the username :"))
    instance.download_profile(user_name, profile_pic_only=True)

def download_stories():
    user_name = str(input("enter the username :"))
    password = str(getpass.getpass())
    instance.login(user_name, password)
    for story in instance.get_stories():
        for item in story.get_items():
            instance.download_storyitem(item, ':stories')

download_profile()