Lightweight X/Twitter timeline client (GraphQL via cURL or auth strategies)
Project description
X-Timeline Scraper
A Python client to scrape tweets from X (formerly Twitter) timelines using a cURL command.
Introduction
This project provides a Python client to scrape tweets from X (formerly Twitter) timelines using a cURL command. It leverages asynchronous programming for efficient data retrieval and includes features for parsing tweet data.
Table of Contents 🗂
Installation ⚙️
The required packages to run this code can be found in the requirements.txt file. To run this file, execute the following code block after cloning the repository:
pip install .
or
pip install git+https://github.com/StephanAkkerman/x-timeline-scraper.git
Usage ⌨️
To use the X-Timeline Scraper, you need to provide a cURL command that accesses the desired X timeline. The instructions can be found in curl_example.txt. Then, you can use the XTimelineClient class to fetch and parse tweets.
Here's a simple example of how to use the client:
import asyncio
from src.xclient import XTimelineClient
async with XTimelineClient(
"curl.txt", persist_last_id_path="state/last_id.txt"
) as xc:
tweets = await xc.fetch_tweets(update_last_id=False)
for t in tweets:
print(t.to_markdown())
You can also stream new tweets in real-time:
import asyncio
from src.xclient import XTimelineClient
async with XTimelineClient(
"curl.txt", persist_last_id_path="state/last_id.txt"
) as xc:
async for t in xc.stream(interval_s=5.0):
print(t.to_markdown())
Citation ✍️
If you use this project in your research, please cite as follows:
@misc{project_name,
author = {Stephan Akkerman},
title = {X-Timeline Scraper},
year = {2025},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/StephanAkkerman/x-timeline-scraper}}
}
Contributing 🛠
Contributions are welcome! If you have a feature request, bug report, or proposal for code refactoring, please feel free to open an issue on GitHub. We appreciate your help in improving this project.
License 📜
This project is licensed under the MIT License. See the LICENSE file for details.
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 xtimeline-0.1.0.tar.gz.
File metadata
- Download URL: xtimeline-0.1.0.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d3e61ef793294912658a6e80c72bb8259f38685b7af59d9226084c51579287f
|
|
| MD5 |
4ad12dece170c83fdfa15a87fb662aeb
|
|
| BLAKE2b-256 |
a5af39195cb213cf81cb0b0e07d4f8df6ddf7ed0cd145e128b4eafea110381f2
|
File details
Details for the file xtimeline-0.1.0-py3-none-any.whl.
File metadata
- Download URL: xtimeline-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b465054d2d1afd6511066df2bce26ac42653a158648e2f5336c2d7be86eb3679
|
|
| MD5 |
93e434bf4ef8e9ff28f447c727473ec3
|
|
| BLAKE2b-256 |
b974b1a368f6c47bfc68e0e8bd9dc344f5d78afa370dd30fc348bb7584e55759
|