tchan - Telegram Channel scraper
Python library and command-line interface to scrape Telegram public channels. Since this scraper uses Telegram Channel Web preview, it won't work for:
- Public channels with "Restrict saving content" option enabled
- Private channels
- Public Groups
- Private Groups
It's also not possible to retrieve comments, since they're made on a group.
Installing
pip install tchan # Python library only
pip install tchan[cli] # Library + CLI
Using as a libray
from tchan import ChannelScraper
scraper = ChannelScraper()
for message in scraper.messages("tchantest"):
print(f"New message ({message.type}) from {message.channel}:")
print(f" id={message.id}")
print(f" created_at={message.created_at.isoformat()}")
print(f" text={message.text}")
# TODO: add more parameters
Using as a command-line tool
Scrape one or many channels and save all messages to messages.csv:
tchan messages.csv channel1 [channel2 ... channelN]
Tests
To run all tests, execute:
make test # or just `pytest`
Make sure to install development requirements.
Tests were made on a channel created for this task: tchantest.
Metadata
Release files for tchan 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tchan-0.1.4.tar.gz | 8.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tchan-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.9 kB
Release files / tchan-0.1.4.tar.gz
| Download URL | tchan-0.1.4.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e3c382fca3fa1898ae78b025b8aa6dfea81a75df71d394d9ae1655baf535e321
|
|
BLAKE2b-256 checksum How to use checksums |
5d53ceda0c6b07080029ca3cc8b2bc15b1e9ceef7654789e6b2c610013edbc64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Release files / tchan-0.1.4-py3-none-any.whl
| Download URL | tchan-0.1.4-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
20d267056e7b820c8a7b070ea25dd5dee3255d9512c0e646e69f6d93d8f9e7c8
|
|
BLAKE2b-256 checksum How to use checksums |
f7608ead009daa258388e92ac3276095ef33073a3dc36c7a414afecc35c5b464
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|