# ============================================================ # File: scraper/sites/__init__.py # Purpose: # Site autodetection based on URL. # ============================================================ from scraper.sites.piaotian import PiaotianScraper def get_scraper_for_url(url: str): """ Return the correct scraper instance for a given URL. Later: add more site implementations. """ if "ptwxz" in url or "piaotian" in url: return PiaotianScraper() raise ValueError(f"No scraper available for URL: {url}") # ============================================================ # Backwards-compatibility export for legacy BookScraper # ============================================================ # Old code expects: # from scraper.sites import BookSite # We map that to our new PiaotianScraper implementation. BookSite = PiaotianScraper