Site icon DataFlair

Python Project – Instagram Photo Downloader

python instagram photo downloader project

Master Python with 70+ Hands-on Projects and Get Job-ready - Learn Python

The Instagram Photo Downloader is a Python-based application designed to download photos from public Instagram profiles. It utilises the Instaloader library for fetching the images and tkinter for building a user-friendly graphical interface.

About Python Instagram Photo Downloader Project

The Instagram Photo Downloader automates the process of downloading photos from a specified public Instagram profile. By entering the Instagram username, the application fetches and saves the images to a designated folder on the user’s local machine.

Objectives for Instagram Photo Downloader

Project Setup

Required Libraries

Prerequisites of Python Instagram Photo Downloader

Download the Python Instagram Photo Downloader Project

Please download the source code of the Python Instagram Photo Downloader Project: Python Instagram Photo Downloader Project Code.

Step-by-Step Code Implementation of Python Instagram Photo Downloader

1. Importing Libraries

import instaloader
import os
import tkinter as tk
from tkinter import messagebox, filedialog

2. Downloading Photos

def download_photos(username, download_path):
   loader = instaloader.Instaloader()


   if not os.path.exists(download_path):
       os.makedirs(download_path)


   os.chdir(download_path)


   print(f"Downloading photos from @{username}...")
   try:
       loader.download_profile(username, profile_pic_only=False)
       print(f"Photos downloaded successfully to {download_path}")
       messagebox.showinfo("Success", f"Photos downloaded successfully to {download_path}")
   except Exception as e:
       print(f"An error occurred: {e}")
       messagebox.showerror("Error", f"An error occurred: {e}")

3. Tkinter Interface

def build_gui():
   def start_download():
       username = username_entry.get()
       download_path = path_entry.get()
       if username and download_path:
           download_photos(username, download_path)
       else:
           messagebox.showwarning("Input Error", "Please enter both username and download path")


   def browse_folder():
       folder_selected = filedialog.askdirectory()
       path_entry.delete(0, tk.END)
       path_entry.insert(0, folder_selected)


   root = tk.Tk()
   root.title("DataFlair@Instagram Photo Downloader")


   tk.Label(root, text="Instagram Username:").grid(row=0, column=0, padx=10, pady=10)
   username_entry = tk.Entry(root, width=30)
   username_entry.grid(row=0, column=1, padx=10, pady=10)


   tk.Label(root, text="Download Path:").grid(row=1, column=0, padx=10, pady=10)
   path_entry = tk.Entry(root, width=30)
   path_entry.grid(row=1, column=1, padx=10, pady=10)
   browse_button = tk.Button(root, text="Browse", command=browse_folder)
   browse_button.grid(row=1, column=2, padx=10, pady=10)


   download_button = tk.Button(root, text="Download", command=start_download)
   download_button.grid(row=2, column=1, pady=20)


   root.mainloop()


if __name__ == "__main__":
   build_gui()

Python Instagram Photo Downloader Output

1. Application Interface

2. Setting Download Path

3. Giving Username

4. Downloading Photos

5. Downloaded Folder

Conclusion

The Instagram Photo Downloader project successfully demonstrates the use of the instaloader library to download photos from public Instagram profiles. By providing a simple and user-friendly interface, the application allows users to save their favorite Instagram photos locally. The project can be extended to include additional features such as downloading videos, handling private profiles, and integrating with cloud storage services.

Exit mobile version