| 73 | self.timeout = kwargs.get("timeout", timeout) |
| 74 | |
| 75 | async def scrape(self, url: str) -> str: |
| 76 | if self.backend == "playwright": |
| 77 | return await self.ascrape_playwright(url) |
| 78 | elif self.backend == "selenium": |
| 79 | try: |
| 80 | return await self.ascrape_undetected_chromedriver(url) |
| 81 | except Exception as e: |
| 82 | raise ValueError(f"Failed to scrape with undetected chromedriver: {e}") |
| 83 | else: |
| 84 | raise ValueError(f"Unsupported backend: {self.backend}") |
| 85 | |
| 86 | async def ascrape_undetected_chromedriver(self, url: str) -> str: |
| 87 | """ |