Skip to main content

Automatically unfollow non-followers on Instagram with influencer filtering and live logging.

Project description

insta-pruner

PyPI version Python License: MIT

A Python library to automatically unfollow non-followers on Instagram, with influencer filtering and live logging.

Connects to your already-open, logged-in Chrome browser — no credentials stored, no login automation.


📦 Installation

pip install insta-pruner

🚀 Quick Start

Using a file

from insta_pruner import Pruner

pruner = Pruner(
    usernames_file="non_followers.txt",
    threshold=5000,
    inactive_months=6
)
pruner.run()

Using a list directly

from insta_pruner import Pruner

pruner = Pruner(
    usernames=["user1", "user2", "user3"],
    threshold=3000,
    inactive_months=3
)
pruner.run()

⚙️ Parameters

Parameter Type Default Description
usernames_file str None Path to .txt file with one username per line
usernames list None Pass usernames directly as a Python list
threshold int 5000 Accounts with ≥ this many followers are kept (influencer filter)
inactive_months int 6 Unfollow if no post or reel within this many months
unfollowed_log str unfollowed.txt File to log unfollowed accounts (appended, never overwritten)
kept_log str kept_following.txt File to log kept accounts (appended, never overwritten)
debugging_port int 9222 Chrome remote debugging port
pause_before_check int 4 Seconds to wait for each profile page to load
pause_between_users int 2 Seconds to wait between processing each user

Either usernames_file or usernames must be provided. If both are given, usernames takes priority.


💻 Before Running

You must start Chrome with remote debugging enabled so the library can connect to your logged-in session.

PowerShell:

Start-Process "C:\Program Files\Google\Chrome\Application\chrome.exe" -ArgumentList "--remote-debugging-port=9222", "--user-data-dir=C:\chrome-debug"

CMD:

"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --user-data-dir="C:\chrome-debug"

macOS:

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debug

Then log in to Instagram in that Chrome window, and run your Python script.


📏 Unfollow Rules

The usernames list is expected to be non-followers (people who don’t follow you back). The library then applies:

  • Influencer filter — accounts with followers ≥ threshold are always kept
  • Inactivity filter — accounts with no posts or reels in the last inactive_months are unfollowed
  • Both posts (/p/) and reels (/reel/) are checked for last activity

📄 Log Files

Both log files are appended to on every run — previous data is never deleted. Each run is separated by a clear divider:

# UNFOLLOWED ACCOUNTS
# ===========================================================================
# Run started 2026-06-14 19:00:00
# ===========================================================================
# username                  followers   last_active   reason
# ---------------------------------------------------------------------------
@some_account                      320  2023-05-10    followers < 5,000 | last active 2023-05-10 (inactive)

# ===========================================================================
# NEW RUN — 2026-06-15 10:00:00
# ===========================================================================
# username                  followers   last_active   reason
# ---------------------------------------------------------------------------
@another_account                   150  N/A           followers < 5,000 | no posts/reels found

⚠️ Notes

  • Chrome must be open and logged in to Instagram before calling pruner.run()
  • Instagram may rate-limit your account if you process too many users too quickly — increase pause_between_users if needed
  • Private accounts with hidden posts/reels will show last activity as N/A and will be unfollowed if below the threshold
  • This library uses Selenium to automate browser actions — use responsibly

🧑‍💻 Author

Rahul S Rgithub.com/officialsrrahul

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

insta_pruner-0.1.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

insta_pruner-0.1.0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file insta_pruner-0.1.0.tar.gz.

File metadata

  • Download URL: insta_pruner-0.1.0.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for insta_pruner-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d37d89bbf6bf5ab58cef656d14b76eebda38627720db181be650ceff314b32b2
MD5 d9f03a92b982967175ca341f3e4af3a4
BLAKE2b-256 871ee4c0ca406be037c48053a66a876483aff2cbe2117c1858d60cdc41c4945a

See more details on using hashes here.

Provenance

The following attestation bundles were made for insta_pruner-0.1.0.tar.gz:

Publisher: publish.yml on officialsrrahul/insta_pruner_package

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file insta_pruner-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: insta_pruner-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for insta_pruner-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 75613fcbf5c10f07b2afef77a90b3520bececd22c8ac0c4913401991e4c4a584
MD5 bde4ccf915e2329c11dc89ae08719b88
BLAKE2b-256 20846289bf196e7cd8eb4b636e81ea2fa0b01de3ab05749365c3b70c24f6172f

See more details on using hashes here.

Provenance

The following attestation bundles were made for insta_pruner-0.1.0-py3-none-any.whl:

Publisher: publish.yml on officialsrrahul/insta_pruner_package

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page