mirror of
https://huggingface.co/spaces/Catapang1989/aniscrap
synced 2026-04-18 00:01:47 +00:00
Update main.py
This commit is contained in:
15
main.py
15
main.py
@@ -132,18 +132,29 @@ class AnimePahe:
|
|||||||
|
|
||||||
async def _scrape_ids(self, session: str) -> dict:
|
async def _scrape_ids(self, session: str) -> dict:
|
||||||
page = await self.context.new_page()
|
page = await self.context.new_page()
|
||||||
|
try:
|
||||||
|
# 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:
|
try:
|
||||||
await page.goto(
|
await page.goto(
|
||||||
f"{BASE_URL}/anime/{session}",
|
f"{BASE_URL}/anime/{session}",
|
||||||
wait_until="domcontentloaded",
|
wait_until="commit",
|
||||||
timeout=30000,
|
timeout=30000,
|
||||||
)
|
)
|
||||||
|
except Exception as e:
|
||||||
|
if "Timeout" not in str(e):
|
||||||
|
raise e
|
||||||
|
|
||||||
|
# Wait for the main anime content to appear
|
||||||
try:
|
try:
|
||||||
await page.wait_for_selector(
|
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:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
await asyncio.sleep(2)
|
await asyncio.sleep(2)
|
||||||
ids = await page.evaluate("""() => {
|
ids = await page.evaluate("""() => {
|
||||||
let ids = {}
|
let ids = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user