from python_amazon_scraper import ExtractAmazon from flipkart_scraper import scrape_flipkart_price_and_name import asyncio async def scrape(url, platform): try: if platform == "flipkart": # Use our custom working Flipkart scraper that gets both name and price product_name, price = await scrape_flipkart_price_and_name(url) return product_name, price elif platform == "amazon": # Keep using the working Amazon scraper product = ExtractAmazon(url) price = product.get_price() product_name = product.get_title() return product_name, price else: raise ValueError("Unsupported platform") except Exception as e: print(f"Error in scraper: {e}") return None, None