Spaces:
Sleeping
Sleeping
from __future__ import annotations | |
from typing import Literal | |
from pydantic import BaseModel, Field, HttpUrl, ValidationInfo, field_validator | |
class ViewPortModel(BaseModel): | |
width: int = 1280 | |
height: int = 720 | |
class PageModel(BaseModel): | |
color_scheme: Literal["light", "dark", "no-preference"] | None = "no-preference" | |
java_script_enabled: bool | None = True | |
viewport: ViewPortModel | None = None | |
proxy: dict | None = None | |
no_viewport: bool | None = False | |
class GetContentModel(BaseModel): | |
url: HttpUrl | |
query_selector: str | None = None | |
wait_selector: bool | None = False | |
ms_delay: float = Field(default=0.0, gt=-1, lt=15_000.1) | |
def check_query_selector(cls, v: bool | None, info: ValidationInfo) -> bool | None: | |
if v is True and info.data.get("query_selector") is None: | |
msg = "wait_selector cannot be set to True without specifying a query_selector" | |
raise ValueError( | |
msg, | |
) | |
return v | |
class ScreenshotModel(GetContentModel): | |
full_page: bool | None = False | |