Language: Python
Web
Instaloader was created by Thilo Planz to provide a simple and efficient tool for downloading content from Instagram without using the official API. It handles login, private profiles, hashtags, and profiles with ease, and can save metadata like captions, likes, and comments.
Instaloader is a Python library to download Instagram photos, videos, stories, IGTV, and profiles. It allows you to scrape Instagram content programmatically for personal or research purposes.
pip install instaloaderconda install -c conda-forge instaloaderInstaloader can download posts, stories, profiles, or hashtags using Python scripts or command-line interface. It supports login for private profiles, filtering by date, and storing metadata in JSON files.
import instaloader
L = instaloader.Instaloader()
L.download_profile('instagram_username', profile_pic=True)Downloads all posts and profile picture of the specified Instagram user.
import instaloader
L = instaloader.Instaloader()
L.download_stories(userids=['instagram_user_id'])Downloads active stories for the specified user IDs.
import instaloader
L = instaloader.Instaloader()
L.login('your_username', 'your_password')
L.download_profile('private_user', profile_pic=True)Logs in with your credentials to download posts from a private account you follow.
import instaloader
L = instaloader.Instaloader()
for post in instaloader.Hashtag.from_name(L.context, 'python').get_posts():
L.download_post(post, target='#python')Downloads all posts tagged with #python into a folder named '#python'.
import instaloader
L = instaloader.Instaloader(download_comments=False, save_metadata=True)
L.download_profile('instagram_username')Saves JSON metadata for each post, including captions, likes, and comments.
import instaloader
import datetime
L = instaloader.Instaloader()
PROFILE = instaloader.Profile.from_username(L.context, 'instagram_username')
for post in PROFILE.get_posts():
if post.date > datetime.datetime(2025,1,1):
L.download_post(post, target=PROFILE.username)Downloads posts from the profile after January 1, 2025.
Respect Instagram’s terms of service and avoid excessive scraping.
Use login for private content responsibly and only for accounts you have access to.
Handle exceptions for network issues or blocked content.
Save metadata and use structured directories for organization.
Rate-limit requests to avoid temporary bans or throttling.