Home
Softono
x-tweet-fetcher

x-tweet-fetcher

Open source MIT Python
863
Stars
75
Forks
1
Issues
2
Watchers
3 weeks
Last Commit

About x-tweet-fetcher

<div align="center"> # ๐Ÿฆž x-tweet-fetcher **Fetch tweets, lists, articles, and WeChat content โ€” with smart backend routing.** [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) [![OpenClaw Skill](https://img.shields.io/badge/OpenClaw-Skill-blue.svg)](https://github.com/openclaw/openclaw) [![Python 3.7+](https://img.shields.io/badge/Python-3.7+-green.svg)](https://www.python.org) [![GitHub stars](https://img.shields.io/github/stars/ythx-101/x-tweet-fetcher?style=social)](https://github.com/ythx-101/x-tweet-fetcher) *Three backends ยท Auto fallback ยท Works everywhere (VPS / Mac / Windows / CI / Claude Code / OpenClaw)* [Quick Start](#-quick-start) ยท [Backends](#-three-backends) ยท [Capabilities](#-capabilities) ยท [Agent Waystation](#-agent-waystation) ยท [Self-hosted Nitter](#-self-hosted-nitter-setup) ยท [Claude Code & CC](#-works-with-claude-code--cc) </div> --- ## ๐Ÿ˜ค Problem ``` You: fetch that tweet / list / article for me AI: I can't access X/Twitter. Please copy-paste th ...

Platforms

Web Self-hosted

Languages

Python

๐Ÿฆž x-tweet-fetcher

Fetch tweets, lists, articles, and WeChat content โ€” with smart backend routing.

License: MIT OpenClaw Skill Python 3.7+ GitHub stars

Three backends ยท Auto fallback ยท Works everywhere (VPS / Mac / Windows / CI / Claude Code / OpenClaw)

Quick Start ยท Backends ยท Capabilities ยท Agent Waystation ยท Self-hosted Nitter ยท Claude Code & CC


๐Ÿ˜ค Problem

You: fetch that tweet / list / article for me
AI:  I can't access X/Twitter. Please copy-paste the content manually.

You: ...seriously?

X has no free API. Scraping gets you blocked. Browser automation is fragile and won't work in headless environments.

x-tweet-fetcher solves this with smart backend routing: Nitter for zero-dependency speed, Playwright for full-feature coverage, auto fallback between them.

๐Ÿ”€ Three Backends

# Auto mode (default) โ€” Nitter first, browser fallback
python3 scripts/fetch_tweet.py --user elonmusk

# Nitter only โ€” zero dependency, no browser
python3 scripts/fetch_tweet.py --user elonmusk --backend nitter

# Browser only โ€” full features (lists, articles)
python3 scripts/fetch_tweet.py --list 1455045069516357634 --backend browser
Backend Deps Speed Features
nitter None (stdlib only) โšก Fast Timeline, search, replies, profile, mentions
browser Playwright/Chromium ๐Ÿข Slower Everything above + Lists + Articles + fetch_china
auto (default) Best available โšกโ†’๐Ÿข Tries nitter first, falls back to browser

OpenClaw users: Playwright + Chromium are built-in. --backend auto just works โ€” no extra install needed.

๐Ÿ“Š Capabilities

Feature Backend Output
Single tweet FxTwitter (always) text, stats, media, quotes
Reply comments nitter / browser threaded comment list
User timeline nitter / browser paginated tweet list
@mentions monitor nitter / browser incremental new mentions
Keyword search nitter / browser real-time tweet stream
X Lists browser only list member tweets
X Articles browser only full long-form content
User profile analysis nitter + LLM MBTI, Big Five, topic graph
WeChat article search Sogou (direct HTTP) title, url, author, date
WeChat/Weibo/Bilibili browser only via fetch_china.py
Tweet growth tracker FxTwitter API growth curves, burst detection

For AI Agents: All output is structured JSON. Import as Python modules for direct integration. Exit codes are cron-friendly (0=nothing new, 1=new content).

๐Ÿงญ Agent Waystation

x-tweet-fetcher is one of the field tools maintained from Agent Waystation โ€” a stopover for AI agents, builders, tools, and field reports.

If you are building an agent that reads X/Twitter, start from the #22 Teahouse / ่Œถๅบง. It is the active front desk for real usage stories, questions, failures, and agent field notes.

Bring one concrete scene:

  • What does your agent observe?
  • What does it remember?
  • Where does it fail?
  • What field tool does it still need?
  • Which runtime, backend, shipped output, and evidence links would help another builder reproduce it?

From there, tool-specific bugs can move to x-tweet-fetcher issues, and broader agent workflow notes can become Waystation field reports.

Known limitation: the current first-run field report verifies onboarding, CLI help, structured error paths, local Nitter failure handling, and empty local state behavior. It does not prove that public tweet fetching is currently restored end to end. Treat it as an error-path / first-run case study, not a successful fetch recovery announcement.

ไธญๆ–‡๏ผšๅฆ‚ๆžœไฝ ไนŸๅœจๅ…ปไธ€ไธชไผš็œ‹ X/Twitter ็š„ Agent๏ผŒๅ…ˆๆฅ #22 ่Œถๅบง ๅๅใ€‚่ดด้“พๆŽฅใ€่ดดๆŽจๆ–‡ใ€่ดดไฝฟ็”จๅœบๆ™ฏใ€่ดด็ฟป่ฝฆ็Žฐๅœบ้ƒฝๅฏไปฅ๏ผ›่ŒถๅบงไผšๆŠŠๅฎƒๅˆ†ๆตๆˆๅทฅๅ…ท้—ฎ้ข˜ใ€field report๏ผŒๆˆ–่€…ๆ–ฐ็š„ agent ไปปๅŠกใ€‚

โ†’ Join #22 Teahouse / ่ฟ›ๅ…ฅ #22 ่Œถๅบง

๐Ÿš€ Quick Start

Single tweet (zero setup)

# Works immediately โ€” no Nitter, no browser needed
python3 scripts/fetch_tweet.py --url https://x.com/elonmusk/status/123456789

Timeline, search, replies

# Set your Nitter instance URL (for nitter/auto mode)
export NITTER_URL=http://127.0.0.1:8788

# User timeline
python3 scripts/fetch_tweet.py --user elonmusk --limit 20

# Keyword search โ€” real-time tweets
python3 scripts/nitter_client.py --search "AI agent"

# Tweet replies
python3 scripts/fetch_tweet.py --url https://x.com/elonmusk/status/123456789 --replies

# @mentions monitoring (cron-friendly)
python3 scripts/fetch_tweet.py --monitor @yourusername

# User profile analysis
python3 scripts/x-profile-analyzer.py --user elonmusk --count 100

Lists & Articles (browser backend)

# X List โ€” requires Playwright
python3 scripts/fetch_tweet.py --list 1455045069516357634 --backend browser

# X Article
python3 scripts/fetch_tweet.py --article https://x.com/user/article/123 --backend browser

# WeChat / Weibo / Bilibili
python3 scripts/fetch_china.py --url "https://mp.weixin.qq.com/s/..."

WeChat search (always zero-dep)

python3 scripts/sogou_wechat.py --keyword "AI Agent" --limit 5 --json

๐Ÿ–ฅ๏ธ Works with Claude Code / CC

Since x-tweet-fetcher has zero mandatory dependencies, it works perfectly in constrained environments:

Environment nitter mode browser mode Notes
Claude Code (CC) โœ… โŒ No browser runtime
OpenClaw โœ… โœ… Playwright built-in
VPS (headless Linux) โœ… โœ…* *needs pip install playwright
Mac / Windows โœ… โœ…* *needs pip install playwright
CI/CD pipelines โœ… โš ๏ธ Possible but heavy
Docker containers โœ… โš ๏ธ Needs Chromium in image
Termux (Android) โœ… โŒ No Chromium
# In Claude Code (nitter mode, zero deps):
export NITTER_URL=http://your-vps:8788
python3 scripts/fetch_tweet.py --user YuLin807 --limit 10

# In OpenClaw (auto mode, full features):
python3 scripts/fetch_tweet.py --user YuLin807 --limit 10
# โ†’ auto-detects Nitter, falls back to Playwright if needed

๐Ÿ”ง Self-hosted Nitter Setup

โš ๏ธ Public Nitter instances are dead or unreliable (as of March 2026). Self-hosting is the only reliable option.

Why you need this

Twitter removed guest API access in 2023. Public Nitter instances get rate-limited because thousands of users share a few accounts. Your own instance = your own rate limits.

5-minute setup guide

1. Install dependencies

# Ubuntu/Debian
sudo apt install -y redis-server libpcre3-dev libsass-dev

# Install Nim
curl https://nim-lang.org/choosenim/init.sh -sSf | sh
export PATH=$HOME/.nimble/bin:$PATH

2. Build Nitter

git clone https://github.com/zedeus/nitter
cd nitter
nimble build -d:release
nimble scss
cp nitter.example.conf nitter.conf

3. Get X session cookies

Use a secondary account (not your main).

  1. Log into X in browser โ†’ DevTools โ†’ Application โ†’ Cookies โ†’ x.com
  2. Copy auth_token and ct0
  3. Create sessions.jsonl:
{"kind":"cookie","username":"myaccount","authToken":"YOUR_AUTH_TOKEN","ct0":"YOUR_CT0"}

4. Configure

[Server]
address = "127.0.0.1"  # Local only!
port = 8788

[Config]
hmacKey = "$(openssl rand -hex 32)"

[Tokens]
tokenFile = "sessions.jsonl"

5. Run & test

sudo systemctl start redis-server
./nitter

# Test
curl http://127.0.0.1:8788/YuLin807
export NITTER_URL=http://127.0.0.1:8788
python3 scripts/nitter_client.py --search "test"

Security

  • Bind to 127.0.0.1 only โ€” never expose to public internet
  • Use a secondary X account โ€” session token gives full access
  • Session tokens last ~1 year

๐Ÿ“ How It Works

                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 --url              โ”‚  FxTwitter  โ”‚  โ† Public API, no auth needed
                    โ”‚  (free)     โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                           โ”‚ JSON
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ”‚    --backend auto       โ”‚
              โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 --user       โ”‚  โ”‚Nitter โ”‚โ†’โ†’โ”‚Browser โ”‚  โ”‚       โ”‚  Agent   โ”‚
 --replies    โ”‚  โ”‚(fast) โ”‚  โ”‚(full)  โ”‚  โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚  (JSON)  โ”‚
 --monitor    โ”‚  โ”‚ 0 dep โ”‚  โ”‚Playwrt โ”‚  โ”‚       โ”‚          โ”‚
 --search     โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
 --list       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
 --article
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 sogou_wechat โ”‚   Sogou     โ”‚  โ† Direct HTTP, no API key
 fetch_china  โ”‚  (search)   โ”‚
              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
  • Single tweets: FxTwitter โ€” always works, zero auth
  • Timeline / Replies / Search / Mentions: Self-hosted Nitter or Playwright browser
  • Lists / Articles: Playwright browser (Nitter doesn't support these)
  • WeChat / China platforms: Sogou search + fetch_china.py

๐Ÿ“ฆ Requirements

Python 3.7+     (that's it for nitter mode)
Mode Extra requirement
--backend nitter Nothing (Python stdlib only)
--backend browser pip install playwright + playwright install chromium
--backend auto Uses whatever is available

โฐ Cron Integration

Exit codes for automation: 0=nothing new, 1=new content, 2=error.

# Check mentions every 30 min
*/30 * * * * NITTER_URL=http://127.0.0.1:8788 python3 fetch_tweet.py --monitor @username

# Discover tweets daily
0 9 * * * python3 nitter_client.py --search "AI Agent" >> ~/discoveries.jsonl

๐Ÿค Contributing

Issues and PRs welcome! Core platforms:

  • X/Twitter โ€” Nitter + Playwright backends
  • WeChat articles โ€” Sogou search

Other platforms welcome as community PRs.

๐Ÿ™ Acknowledgments

  • Nitter by zedeus (12.6k โญ) โ€” self-hosted Twitter frontend
  • FxTwitter โ€” public API for single tweet data
  • Playwright โ€” browser automation for full-feature coverage
  • OpenClaw โ€” AI agent framework

๐Ÿ“„ License

MIT


Three backends. Auto fallback. Works everywhere. ๐Ÿฆž

GitHub ยท Issues ยท #22 Teahouse ยท Agent Waystation