Skip to content

matannahmani/insta-tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Instagram Snapshot Tracker

A simple CLI tool + Streamlit viewer to track followers and following lists for one or more Instagram accounts.

Features

  • CLI Tracker (main.py):

    • Logs in with Instaloader (supports 2FA, sessions, etc.).
    • Fetches a user's current followers/following.
    • Compares them to the most recent snapshot to detect who was gained or lost.
    • Saves a new snapshot to [username]/followers/*.txt and [username]/following/*.txt.
  • Streamlit Viewer (viewer.py):

    • Allows you to browse snapshots from your browser.
    • Compare two snapshots to see who was gained or lost.
    • Displays clickable links to https://instagram.com/username.
    • Collapsible sections to keep UI neat, with focus on differences.

Installation

  1. Clone this repository:

    git clone https://github.com/your-username/insta-tracker.git
    cd insta-tracker
  2. Install dependencies:

    pip install instaloader rich python-dotenv streamlit pandas
  3. Optional: create a .env file to store your login:

    # .env
    INSTAGRAM_USERNAME=your_ig_username
    INSTAGRAM_PASSWORD=your_ig_password

    This is optional; otherwise you'll be prompted during main.py to enter credentials (or load a session file).

Usage

1) Track & Save Snapshots

Run the tracker once (or schedule it) to grab followers/following:

python main.py
  • If it's your first time running:
    • You can choose to load an existing session (if you have SESSION-<USER> files).
    • Or use .env credentials.
    • Or type in username/password directly (2FA is supported).
  • The script will:
    • Prompt for which user you want to track.
    • Fetch followers/following.
    • Compare to the last snapshot to see changes.
    • Save a new snapshot under [username]/followers/<timestamp>.txt and [username]/following/<timestamp>.txt.

Repeat this daily/weekly for consistent snapshots.

2) View Snapshots in Browser

Launch the Streamlit viewer:

streamlit run viewer.py
  • Open http://localhost:8501 in your browser.
  • Pick a user (any directory that has followers/ or following/ subfolders).
  • Choose "followers" or "following."
  • Single snapshot or Compare two snapshots.
  • Differences appear at the top (lost/gained).
  • Links are clickable to open each user's IG profile.

Session Files

When you log in via Instaloader, it saves a file called SESSION-<INSTAGRAM_USERNAME> which stores your session cookies. Next time you run main.py, you can load that session to skip logging in again.

  • If you change your Instagram password or the session expires, you'll need to log in again.

File Structure

After several runs, your project might look like:

.
├─ main.py
├─ viewer.py
├─ tracker_config.json
├─ .env  (optional)
├─ SESSION-<account>  (example session file)
├─ <tracked-account>/
│  ├─ followers/
│  │  ├─ 2023-12-10_09-00-00.txt
│  │  └─ 2023-12-11_09-00-00.txt
│  └─ following/
│     ├─ 2023-12-10_09-00-00.txt
│     └─ 2023-12-11_09-00-00.txt
├─ ...
└─ ...

License

MIT License

Please read the LICENSE file for full details. In short, you are free to use, modify, and distribute this code, provided you include the copyright notice.

Contributing

  • Please open an issue or PR if you’d like to enhance the script or viewer.
  • This project is meant for personal usage. Please respect Instagram’s Terms of Service and do not abuse rate limits or violate user privacy.

Disclaimer

Use at your own risk. Instagram can change its internal APIs or DOM structure at any time.
This code is not affiliated with or endorsed by Instagram, Meta, or any related entities.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages