Update main.py

This commit is contained in:
Aira Catapang
2026-03-18 10:58:20 +00:00
committed by system
parent 004bf66576
commit c8e677c025

23
main.py
View File

@@ -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 = {}