| name | x-thread-scrape |
| description | Scrape full X tweet text from a seed tweet URL, including same-author continuation posts in the thread and related images, using patchright with Netscape cookies. |
X Thread Scrape
Use this skill when you need reproducible capture of:
- Seed tweet full text
- Same-author continuation posts in the thread
- Related image URLs and downloaded image files
Language guides:
Workflow
- Install dependency (if missing):
pip install patchright
-
Prepare cookie file in Netscape format (example: H:\cookies\x.txt).
-
Run script:
python E:\projectHome\skill_grok\skill\x-thread-scrape\scripts\query_x_thread.py `
--cookie-file H:\cookies\x.txt `
--tweet-url "https://x.com/<handle>/status/<tweet_id>" `
--output-dir E:\projectHome\skill_grok `
--basename x_thread_result `
--wait-seconds 240
- Check outputs:
<basename>_thread.json: structured thread output (tweets + images info)
<basename>_posts.jsonl: one tweet per line
<basename>_meta.json: run metadata and output paths
<basename>_images/: downloaded images
Script
Use query_x_thread.py.
Key flags:
--cookie-file: Netscape cookie txt path (required)
--tweet-url: X seed tweet URL (required)
--output-dir: output directory (default .)
--basename: output prefix (default x_thread_result)
--wait-seconds: max thread expansion wait (default 180)
--max-scrolls: scroll attempts to load thread continuation (default 30)
--scroll-wait-ms: wait per scroll (default 1500)
--headless: run browser headless
--include-all-authors: include non-seed-author tweets
--no-download-images: keep image URLs only, skip image downloads
Thread Semantics
Default behavior captures tweets authored by the same handle as the seed tweet URL.
Use --include-all-authors if you want replies from other authors too.
Failure Handling
If thread capture is incomplete:
- Increase
--wait-seconds and --max-scrolls.
- Run without
--headless to inspect the page behavior.
- Refresh cookie file and retry.
If image download fails:
- Keep the image
source_url and normalized_url from JSON as ground truth.
- Retry with stable network or another cookie session.