mirror of
https://github.com/ThePhaseless/Byparr.git
synced 2025-03-15 09:50:20 +08:00
print current html on error
This commit is contained in:
parent
d0b9e7f324
commit
99c90ddc23
13
main.py
13
main.py
@ -3,7 +3,6 @@ from __future__ import annotations
|
|||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
import uvicorn
|
import uvicorn
|
||||||
import uvicorn.config
|
import uvicorn.config
|
||||||
@ -39,16 +38,14 @@ async def read_item(request: LinkRequest):
|
|||||||
timeout = None
|
timeout = None
|
||||||
try:
|
try:
|
||||||
challenged = await asyncio.wait_for(bypass_cloudflare(page), timeout=timeout)
|
challenged = await asyncio.wait_for(bypass_cloudflare(page), timeout=timeout)
|
||||||
except asyncio.TimeoutError as e:
|
except Exception as e:
|
||||||
i = 0
|
logger.error(await page.get_content())
|
||||||
while Path(f"errors/error{i}.png").is_file():
|
logger.fatal("Element is a string, please report this to Byparr dev")
|
||||||
i += 1
|
raise HTTPException(detail="Couldn't bypass", status_code=408) from e
|
||||||
await page.save_screenshot(f"errors/error{i}.png")
|
|
||||||
raise HTTPException(detail="Timeout", status_code=408) from e
|
|
||||||
|
|
||||||
logger.info(f"Got webpage: {request.url}")
|
logger.info(f"Got webpage: {request.url}")
|
||||||
|
|
||||||
response = LinkResponse.create(
|
response = await LinkResponse.create(
|
||||||
page=page,
|
page=page,
|
||||||
start_timestamp=start_time,
|
start_timestamp=start_time,
|
||||||
challenged=challenged,
|
challenged=challenged,
|
||||||
|
@ -81,7 +81,6 @@ async def bypass_cloudflare(page: webdriver.Tab):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
if not isinstance(elem, Element):
|
if not isinstance(elem, Element):
|
||||||
logger.fatal("Element is a string, please report this to Byparr dev")
|
|
||||||
raise InvalidElementError
|
raise InvalidElementError
|
||||||
|
|
||||||
elem = await page.find("input")
|
elem = await page.find("input")
|
||||||
|
@ -11,8 +11,8 @@ client = TestClient(app)
|
|||||||
test_websites = [
|
test_websites = [
|
||||||
"https://ext.to/",
|
"https://ext.to/",
|
||||||
"https://btmet.com/",
|
"https://btmet.com/",
|
||||||
# "https://extratorrent.st/", # github is blocking these
|
"https://extratorrent.st/", # github is blocking these
|
||||||
# "https://idope.se/", # github is blocking these
|
"https://idope.se/", # github is blocking these
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user