This project is a two-in-one script that:
- Scrapes saved reels from a specified Instagram collection
- Automatically sends them to a Telegram chat and deletes them after a short delay
- Automated Login: Uses cookies to avoid logging in every time.
- Scrape Instagram Reels: Extracts all saved reels from a given collection.
- Send to Telegram: Automatically sends the scraped reels to a specified Telegram chat.
- Auto-Delete Messages: Deletes each sent reel after a short delay.
- Python 3.7+
- Selenium (undetected_chromedriver)
- Pyrogram (Telegram client)
- An Instagram account with saved reels
- A Telegram bot with access to the target chat
- Clone the repository:
git clone https://github.com/tars-06/reelstotg.git cd ReelsToTG - Install dependencies:
pip install -r requirements.txt
-
Instagram Credentials:
- Update
USERNAMEandPASSWORDin the script for the first-time login. - Cookies will be saved automatically to avoid re-login.
- Update
-
Telegram API:
- Get your
API_IDandAPI_HASHfrom my.telegram.org. - Set up a session file for Pyrogram.
- Specify the
chat_idwhere reels should be sent.
- Get your
-
Collection URL:
- Update
COLLECTION_URLwith the link to your saved reels collection.
- Update
Run the script to scrape and send reels:
python main.py- The script logs into Instagram (or loads saved cookies).
- It scrapes all reel links from the specified collection.
- The links are saved to
reels.txt. - The Telegram bot reads the links and sends them to the chat.
- Each message is deleted after a short delay.
- Ensure your Instagram account is logged in and verified.
- Use a VPN if Instagram blocks automation attempts.
- Your Telegram bot must have permission to send and delete messages in the target chat.
- Error Handling: Improve exception handling for network failures and login issues.
- Auto Scrolling: Automate scrolling to load all reels without manual input.
- Parallel Sending: Use
asyncio.gather()to speed up the sending process. - Smart Deletion Timing: Randomize deletion time to avoid detection patterns.
- Headless Mode: Fully enable headless scraping for efficiency.
- Config File: Store credentials & settings in a
.envfile instead of hardcoding. - Logging: Save logs of sent and deleted messages for tracking.
- Multi-Account Support: Enable handling of multiple Instagram or Telegram accounts.
This project is for educational purposes only. Use responsibly.