mirror of
https://huggingface.co/spaces/Catapang1989/aniscrap
synced 2026-04-17 15:51:46 +00:00
Update main.py
This commit is contained in:
23
main.py
23
main.py
@@ -133,17 +133,28 @@ class AnimePahe:
|
||||
async def _scrape_ids(self, session: str) -> dict:
|
||||
page = await self.context.new_page()
|
||||
try:
|
||||
await page.goto(
|
||||
f"{BASE_URL}/anime/{session}",
|
||||
wait_until="domcontentloaded",
|
||||
timeout=30000,
|
||||
)
|
||||
# 1. Apply stealth to bypass Cloudflare on the info page
|
||||
await Stealth().apply_stealth_async(page)
|
||||
|
||||
# 2. Use wait_until="commit" and catch timeouts just like we did in resolve
|
||||
try:
|
||||
await page.goto(
|
||||
f"{BASE_URL}/anime/{session}",
|
||||
wait_until="commit",
|
||||
timeout=30000,
|
||||
)
|
||||
except Exception as e:
|
||||
if "Timeout" not in str(e):
|
||||
raise e
|
||||
|
||||
# Wait for the main anime content to appear
|
||||
try:
|
||||
await page.wait_for_selector(
|
||||
"div.anime-info, div.anime-summary, aside, main", timeout=10000
|
||||
"div.anime-info, div.anime-summary, aside, main", timeout=15000
|
||||
)
|
||||
except:
|
||||
pass
|
||||
|
||||
await asyncio.sleep(2)
|
||||
ids = await page.evaluate("""() => {
|
||||
let ids = {}
|
||||
|
||||
Reference in New Issue
Block a user