Skip to content

Latest commit

Β 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎬 Como TV Scraper

A powerful web scraper for Como TV content with Telegram bot control

Python License

Features β€’ Quick Start β€’ Documentation β€’ Telegram Bot


✨ Features

πŸ” Web Scraping

  • πŸ“¦ Scrape 1-1000 categories automatically
  • πŸ“„ Extract detailed content information
  • πŸ”— Fetch related content (up to 10 items)
  • 🌐 Multi-language support (IT/EN)
  • πŸ”„ Automatic retry mechanism
  • ⏱️ Smart rate limiting

πŸ€– Telegram Bot

  • πŸ“± Remote control via Telegram
  • πŸ“Š Real-time progress tracking
  • πŸ“₯ Direct file downloads
  • βš™οΈ Live configuration updates
  • 🧹 Integrated data cleaning
  • 🌍 Proxy support

πŸ›‘οΈ Additional Features

  • βœ… Multi-threading (4 parallel workers for 4x speed)
  • βœ… Proxy support (HTTP/HTTPS) with authentication
  • βœ… 3x retry mechanism for all requests (SSLError, Timeout, etc.)
  • βœ… Duplicate removal & data cleaning
  • βœ… Fancy progress bar with live stats & ETA
  • βœ… CSV export with custom fields
  • βœ… Environment-based configuration (.env)
  • βœ… Error handling & logging

πŸš€ Quick Start

1️⃣ Installation

# Clone repository
git clone https://github.com/Veloruze/como-tv-scraper.git
cd como-tv-scraper

# Install dependencies
pip install -r requirements.txt

2️⃣ Configuration

Create .env file from template:

cp .env.example .env

Edit .env with your settings:

# Telegram Bot (optional - only if using bot)
TELEGRAM_BOT_TOKEN=your_bot_token_here

# Proxy Configuration
PROXY_URL=http://username:password@proxy.com:port
PROXY_ENABLED=true

# Scraper Settings
LANGUAGE_CODE=it-IT
CATEGORY_START=1
CATEGORY_END=1000
MAX_WORKERS=4

3️⃣ Run Scraper

# Scrape categories
python como_tv_scraper.py

# Clean data (remove duplicates)
python clean_data.py

# Scrape details
python detail_scraper.py

πŸ€– Telegram Bot

Control everything from Telegram with an interactive bot interface!

Setup Telegram Bot

  1. Create Bot

    • Open Telegram β†’ Search @BotFather
    • Send /newbot and follow instructions
    • Copy the bot token
  2. Configure

    TELEGRAM_BOT_TOKEN=1234567890:ABCdefGHIjklMNOpqrsTUVwxyz
  3. Run Bot

    python telegram_bot.py

Bot Commands

Command Description
/start Show main menu with interactive buttons
/setlang <code> Set language (it-IT or en_US)
/setproxy <url> Configure proxy URL
/setrange <start> <end> Set category range
/toggleproxy Enable/disable proxy

Interactive Menu

πŸ“ Scrape Categories  β†’  Scrape all categories
πŸ“„ Scrape Details    β†’  Get detailed content info
🧹 Clean Data        β†’  Remove duplicates
πŸ“Š Status            β†’  Check scraping progress
βš™οΈ Settings          β†’  View configuration
πŸ“₯ Download          β†’  Get CSV files

Workflow

graph LR
    A[πŸ“ Scrape Categories] --> B[🧹 Clean Data]
    B --> C[πŸ“„ Scrape Details]
    C --> D[πŸ“₯ Download Results]
Loading

πŸ“– Documentation

Category Scraper

Scrapes content from categories with pagination support.

from como_tv_scraper import ComoTVScraper, ScraperConfig

# Auto-load from .env
config = ScraperConfig()
scraper = ComoTVScraper(config)

# Scan categories
scraper.scan_all_categories(
    start_id=1,
    end_id=1000,
    output_file="output/all_categories.csv"
)

Output: categoryId, categoryName, title, contentId

Detail Scraper

Fetches detailed information for each content item.

from detail_scraper import ComoTVDetailScraper, load_content_ids_from_csv

# Load config from .env
scraper = ComoTVDetailScraper()

# Load content IDs from categories
content_ids = load_content_ids_from_csv("output/all_categories_cleaned.csv")

# Scrape details
scraper.scrape_multiple_details(
    content_ids=content_ids,
    output_file="output/content_details.csv"
)

Output: contentId, name, type, templateModel, area, contentGrade, description, duration, categoryName, watermarkId, RelatedCount, Related1-10

Data Cleaning

Remove duplicates and empty rows automatically.

from clean_data import clean_categories_csv, clean_details_csv

# Clean category data
clean_categories_csv()

# Clean details data
clean_details_csv()

βš™οΈ Configuration

Environment Variables

Variable Default Description
TELEGRAM_BOT_TOKEN - Telegram bot token from @BotFather
PROXY_URL - Proxy URL with credentials
PROXY_ENABLED true Enable/disable proxy
LANGUAGE_CODE it-IT API language (see Language Options below)
CATEGORY_START 1 Start category ID
CATEGORY_END 1000 End category ID
MAX_WORKERS 4 Number of parallel threads (1-10 recommended)

Proxy Format

http://username:password@host:port

Example:

http://user123-country-it:pass456@proxy.com:6060

Language Options

Code Language Status Notes
it-IT Italian (Italy) βœ… Recommended Excellent data quality, best results
en_US English (US) ⚠️ Limited Poor/no data availability

Note: Como TV is Italy-based, so Italian language provides the most comprehensive content.


πŸ“ Project Structure

como-tv-scraper/
β”œβ”€β”€ πŸ“„ como_tv_scraper.py      # Category scraper
β”œβ”€β”€ πŸ“„ detail_scraper.py       # Detail scraper
β”œβ”€β”€ πŸ“„ clean_data.py           # Data cleaning utility
β”œβ”€β”€ πŸ€– telegram_bot.py         # Telegram bot interface
β”œβ”€β”€ πŸ“‹ requirements.txt        # Python dependencies
β”œβ”€β”€ πŸ”§ .env.example            # Configuration template
β”œβ”€β”€ πŸ“– README.md               # This file
└── πŸ“‚ output/                 # Output directory
    β”œβ”€β”€ all_categories.csv           # Raw category data
    β”œβ”€β”€ all_categories_cleaned.csv   # Cleaned categories
    β”œβ”€β”€ content_details.csv          # Raw details
    └── content_details_cleaned.csv  # Cleaned details

πŸ”§ Troubleshooting

Connection Errors / Timeouts
  • βœ… Script auto-retries 3x with 5s delay
  • βœ… Increase timeout in scraper config
  • βœ… Check proxy connection
  • βœ… Verify internet stability
Proxy Not Working
  • βœ… Verify proxy URL format
  • βœ… Test proxy: curl -x http://user:pass@proxy:port https://google.com
  • βœ… Check proxy credentials
  • βœ… Try disabling proxy: PROXY_ENABLED=false
Telegram Bot Not Responding
  • βœ… Verify token in .env file
  • βœ… Check bot is running: python telegram_bot.py
  • βœ… Ensure .env file exists and formatted correctly
  • βœ… Check internet connection
No Data Found
  • βœ… Verify language code (it-IT works best)
  • βœ… Check proxy is working (timeout = no data)
  • βœ… Try different category range
  • βœ… Increase timeout to 60s

πŸ“Š Sample Output

Category Scraping

Starting scan of categories 1 to 1000...
Proxy enabled: True
Language: it-IT

[206/1000] Scanning category 206...
  Scraping page 0...
  Scraping page 1...
  Found 45 items

==================================================
SCAN COMPLETE!
==================================================
Total categories scanned: 1000
Successful: 127
Failed/Empty: 873
Total items collected: 4,325
Output file: output/all_categories.csv
==================================================

Detail Scraping

Scraping content details with 4 workers...
100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 4325/4325 [1:23:45<00:00, 51.67it/s]

Results:
  βœ“ Successful: 4,312
  βœ— Failed: 13
  πŸ“Š Total: 4,325

Output saved to: output/content_details.csv

πŸ” Security

⚠️ Important Security Notes

  • πŸ”’ NEVER commit .env file to git (already in .gitignore)
  • πŸ”’ NEVER share your Telegram bot token publicly
  • πŸ”’ Keep proxy credentials secure
  • πŸ”’ Use .env.example as template only (no real credentials)

πŸ“¦ Requirements

  • Python 3.8 or higher
  • requests >= 2.31.0
  • python-telegram-bot >= 20.0 (for bot only)
  • python-dotenv >= 1.0.0
  • tqdm >= 4.66.0 (for progress bars)

πŸ“ License

MIT License - see LICENSE file for details


🀝 Contributing

Contributions are welcome! Feel free to:

  • πŸ› Report bugs
  • πŸ’‘ Suggest features
  • πŸ”§ Submit pull requests

Made with ❀️ using Python

⬆ Back to Top

About

Como TV content scraper with Telegram bot control, proxy support, and CSV export. Scrapes categories, content details, and related items.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages