A Python CLI tool for scraping public X (Twitter) profile tweets using Playwright.
Project description
TwitterXScraper
A Lightweight Python tool for scraping public X (Twitter) tweets using Playwright.
I needed a simple way to pull public tweets from X without touching the API, dealing with tokens, or waiting on rate limits
So I wrote this CLI tool that asks for username, opens a Chromium browser with Playwright, scrolls a profile, grabs tweet text and timestamps, and dumps everything into a CSV.
PyPI: https://pypi.org/project/twitterxscraper
Features
- Scrape public tweets from any username
- Automatically scroll to load more tweets
- Extract tweet text
- Extract tweet timestamps
- Save results to CSv
- Works in the terminal
- Installed with pip
Installation
pip install twitterxscraper
python -m playwright install chromium
Clone this repository
git clone https://github.com/calchiwo/twitterxscraper.git
cd twitterxscraper
Install dependencies.
python -m pip install -e .
python -m playwright install chromium
How it use
Run the CLI and pass a username:
python twitterxscraper elonmusk
With a custom limit:
python twitterxscraper elonmusk --limit 15
This creates a CSV file named after the username: elonmusk.csv.
Using it in your own code
You can also run it as a module directly as a Python class.
from twitterxscraper import TwitterScraper
scraper = TwitterScraper()
tweets = scraper.scrape_user("elonmusk", limit=10)
print(tweets)
Limitations
- Only works on public profiles
- No login support
- No private acconts
- Breaks if X layout changes
- Uses a Chromium browser with Playwright
This is scraping. Layout changes can
Tech stack used
- Python
- Playwright
- Pandas
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file twitterxscraper-1.1.3.tar.gz.
File metadata
- Download URL: twitterxscraper-1.1.3.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27c73ed77222955042a1a76dc201b7aac33001fb9bf5ee0add5a50b33a011c63
|
|
| MD5 |
e7fec60e00a6cc67f5a0196865baca06
|
|
| BLAKE2b-256 |
e2f3d8be41be76901bb6ea6b85da65333e608d5563f3cb29ee5108fafc28977c
|
File details
Details for the file twitterxscraper-1.1.3-py3-none-any.whl.
File metadata
- Download URL: twitterxscraper-1.1.3-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b19b0938194a07ae826e88c93836a161a0e14471b09e99554bfdf048141f51e
|
|
| MD5 |
d4e43c55b5ac263771f8bcad1a3e7d23
|
|
| BLAKE2b-256 |
9d2bfb035cce50fd1c048e12833a8dfcf40560f0ab40a356efd26153dd5ccd6b
|