#!/usr/bin/env python3
"""
Example usage of the News Scraper
Demonstrates how to scrape different news sites with appropriate selectors.
"""

from scraper import NewsScraper


def scrape_bbc():
    """Example: Scrape BBC News"""
    scraper = NewsScraper(output_dir="output")
    
    selectors = {
        'article': '[data-testid="internal-link"]',
        'headline': 'h2, h3',
        'text': 'p',
        'image': 'img'
    }
    
    url = "https://www.bbc.com/news"
    scraper.scrape(url, selectors, title="BBC News Headlines", output_file="bbc_news.html")


def scrape_custom_site():
    """Example: Scrape a custom news site"""
    scraper = NewsScraper(output_dir="output")
    
    # Adjust these selectors based on your target website's structure
    selectors = {
        'article': 'article',           # Main article container
        'headline': 'h1, h2, h3',       # Headline
        'text': 'p',                    # Article text
        'image': 'img'                  # Article image
    }
    
    url = "https://www.investing.com/technical/technical-analysis"
    scraper.scrape(url, selectors, title="News", output_file="investing_news.html")


def scrape_hacker_news():
    """Example: Scrape Hacker News"""
    scraper = NewsScraper(output_dir="output")
    
    selectors = {
        'article': '.athing',
        'headline': '.titleline > a',
        'text': '.titleline',
        'image': 'img'
    }
    
    url = "https://news.ycombinator.com"
    scraper.scrape(url, selectors, title="Hacker News", output_file="hacker_news.html")


if __name__ == "__main__":
    print("Running example scraping tasks...\n")
    
    # Uncomment the example you want to run:
    
    scrape_bbc()
    scrape_custom_site()
    scrape_hacker_news()
    
    print("\nTo use these examples:")
    print("1. Uncomment the function call you want to run")
    print("2. Adjust the selectors for your target website")
    print("3. Run: python example_usage.py")
    print("\nTip: Use your browser's Inspector (F12) to find the right CSS selectors")
