A Python script that lets you automatedally scrape and obtain tales out of your Telegram associates utilizing the Telethon library. The script repeatedly displays and saves each images and movies from tales, together with their metadata.
Vital Observe About Story Entry ⚠️
As a result of Telegram API restrictions, this script can solely entry tales from: – Customers you will have added to your buddy listing – Customers whose privateness settings will let you view their tales
It is a limitation of Telegram’s API and can’t be bypassed.
Options 🚀
- Robotically scrapes all out there tales out of your Telegram associates
- Downloads each images and movies from tales
- Shops metadata in SQLite database
- Exports knowledge to Excel spreadsheet
- Actual-time monitoring with customizable intervals
- Timestamp is about to (UTC+2)
- Maintains report of beforehand downloaded tales
- Resume functionality
- Automated retry mechanism
Stipulations 📋
Earlier than working the script, you will want:
- Python 3.7 or larger
- Telegram account
- API credentials from Telegram
- Mates on Telegram whose tales you wish to monitor
Required Python packages
pip set up -r necessities.txt
Contents of necessities.txt
:
telethon
openpyxl
schedule
Getting Telegram API Credentials 🔑
- Go to https://my.telegram.org/auth
- Log in together with your cellphone quantity
- Click on on “API improvement instruments”
- Fill within the kind:
- App title: Your app title
- Quick title: Your app quick title
- Platform: Might be left as “Desktop”
- Description: Transient description of your app
- Click on “Create software”
- You may obtain:
api_id
: A quantityapi_hash
: A string of letters and numbers
Maintain these credentials protected, you will want them to run the script!
Setup and Operating 🔧
- Clone the repository:
git clone https://github.com/unnohwn/telegram-story-scraper.git
cd telegram-story-scraper
- Set up necessities:
pip set up -r necessities.txt
- Run the script:
python TGSS.py
- On first run, you will be prompted to enter:
- Your API ID
- Your API Hash
- Your cellphone quantity (with nation code)
- Verification code (despatched to your Telegram)
- Checking interval in seconds (default is 60)
How It Works 🔄
The script: 1. Connects to your Telegram account 2. Periodically checks for brand spanking new tales from your pals 3. Downloads any new tales (images/movies) 4. Shops metadata in a SQLite database 5. Exports data to an Excel file 6. Runs repeatedly till interrupted (Ctrl+C)
Information Storage 💾
Database Construction (tales.db)
SQLite database containing: – user_id
: Telegram consumer ID of the story creator – story_id
: Distinctive story identifier – timestamp
: When the story was posted (UTC+2) – filename
: Native filename of the downloaded media
CSV and Excel Export (stories_export.csv/xlsx)
Export file containing the identical data because the database, helpful for: – Straightforward viewing of story metadata – Filtering and sorting – Information evaluation – Sharing knowledge with others
Media Storage 📁
- Images are saved as:
{user_id}_{story_id}.jpg
- Movies are saved with their unique extension:
{user_id}_{story_id}.{extension}
- All media information are saved within the script’s listing
Options in Element 🔍
Steady Monitoring
- Customizable checking interval (default: 60 seconds)
- Runs repeatedly till manually stopped
- Maintains state between runs
- Avoids duplicate downloads
Media Dealing with
- Helps each images and movies
- Robotically detects media sort
- Preserves unique high quality
- Generates distinctive filenames
Error Dealing with 🛠️
The script consists of: – Automated retry mechanism for failed downloads – Error logging for failed operations – Connection error dealing with – State preservation in case of interruption
Limitations ⚠️
- Topic to Telegram’s fee limits
- Tales should be at present lively (not expired)
- Media obtain measurement limits apply as per Telegram’s restrictions
Contributing 🤝
Contributions are welcome! Please be at liberty to submit a Pull Request.
License 📄
This undertaking is licensed beneath the MIT License – see the LICENSE file for particulars.
Disclaimer ⚖️
This software is for instructional functions solely. Ensure to: – Respect Telegram’s Phrases of Service – Get hold of crucial permissions earlier than scraping – Use responsibly and ethically – Adjust to knowledge safety laws – Respect consumer privateness