Skip to main content

Threads Comment Scraper

A keyword-based CLI scraper for Threads comments and replies — no account required.

Python 3.10+ License: MIT PyPI


Features

  • Keyword search: search Threads by any keyword and collect all matching comments and replies
  • No account required: session tokens are fetched automatically via headless browser on first run
  • Auto token refresh: detects expired tokens after 3 consecutive 403s and silently refreshes via headless Chromium
  • Text cleaning: removes URLs, @mentions, #hashtags, emoji, and normalizes whitespace
  • Deduplication: skips posts already scraped, tracked across restarts via checkpoint file
  • Resume support: interrupted scrapes continue from where they left off
  • Configurable via CLI: limit, output file, delay range, minimum comment length, checkpoint toggle
  • CSV output with columns: post_code, post_id, post_text, comment_id, comment_text, username, like_count, reply_count, timestamp, keyword, type

Installation

pip install threads-comment-scraper
playwright install chromium

Usage

# Scrape by inline keywords
threads-scraper --keywords "politik indonesia,pilkada"

# Use a keywords file
threads-scraper --keywords-file keywords.txt

# With all options
threads-scraper --keywords-file keywords.txt \

  --output data.csv \
  --limit 5000 \
  --delay-min 2 \
  --delay-max 5 \
  --min-length 15

keywords.txt format

Lines starting with # are treated as comments and ignored.

# Politik
politik indonesia
pilkada

# Ekonomi
ekonomi indonesia
bbm naik

CLI reference

Argument Default Description
--keywords — Comma-separated keyword string
--keywords-file — Path to .txt file, one keyword per line
--limit unlimited Maximum total comments to collect
--output output.csv Output CSV file path
--min-length 10 Minimum character count per comment
--delay-min 2.0 Minimum seconds between requests
--delay-max 5.0 Maximum seconds between requests
--no-checkpoint off Disable resume behavior (start fresh)

Output CSV columns

Column Description
post_code Original post shortcode from the URL (e.g. DYeZUeiElWy)
post_id Numeric media ID used by the GraphQL API
post_text Text of the top-level post being replied to
comment_id Numeric ID of the comment or reply
comment_text Cleaned comment/reply text
username Poster's Threads username
like_count Number of likes on the comment
reply_count Number of direct replies to the comment
timestamp Unix timestamp of the comment
keyword The search keyword that found this post
type comment (top-level) or reply

Notes

  • For educational and research purposes only
  • Respect Threads' Terms of Service
  • Use reasonable delays (--delay-min, --delay-max) to avoid overloading servers
  • The first run launches a headless browser to capture fresh session tokens, this is normal and takes ~10 seconds

Credit

Made by @galihkjaya @Nathaniel7

Metadata

Release files for threads-comment-scraper 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for threads-comment-scraper 0.1.1
File Size Uploaded Provenance Actions
threads_comment_scraper-0.1.1.tar.gz 11.6 kB Without provenance Details for threads_comment_scraper-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for threads-comment-scraper 0.1.1
File Interpreter ABI Platform Actions
threads_comment_scraper-0.1.1-py3-none-any.whl Python 3 none any Details for threads_comment_scraper-0.1.1-py3-none-any.whl

Total release size: 25.6 kB

Release files / threads_comment_scraper-0.1.1.tar.gz

Download URL threads_comment_scraper-0.1.1.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c9795a023d3853f3a0d9c28402e400c47dfc3981158ebe1a4b67295fc4ccff5b
BLAKE2b-256 checksum
How to use checksums
2d043e441fa0946fdc72e403cd6aad74d9fa6f176066ec20b1011bac80d8e8af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.1

Release files / threads_comment_scraper-0.1.1-py3-none-any.whl

Download URL threads_comment_scraper-0.1.1-py3-none-any.whl
Size 14.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7ce327ff78c43655b57c91f683ff8209674aa97622cfa4d934e791597fd36ab2
BLAKE2b-256 checksum
How to use checksums
faae6d5601ecc72d192116f06388f0000a2e02b098ed4a16abfe8cd9f25b214a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.1

Security for threads-comment-scraper 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page