Spaces:
Sleeping
Sleeping
| from __future__ import annotations | |
| from typing import Literal | |
| from pydantic import BaseModel, Field, HttpUrl | |
| class ViewPortModel(BaseModel): | |
| """Page viewport | |
| Attributes: | |
| width (int): | |
| viewport width. | |
| height (int): | |
| viewport height. | |
| """ | |
| width: int = 1280 | |
| height: int = 720 | |
| class PageModel(BaseModel): | |
| """Page attrs | |
| Attributes: | |
| color_scheme (Literal["light", "dark", "no-preference"] | None): | |
| Page color. | |
| java_script_enabled (bool | None): | |
| Whether or not to enable JavaScript in the context. Defaults to true. | |
| viewport (ViewPortModel | None): | |
| Sets a consistent viewport for each page. Defaults to an 1280x720 viewport. | |
| no_viewport (bool | None): | |
| Does not enforce fixed viewport, allows resizing window in the headed mode. | |
| proxy (dict | None): | |
| Proxy to be used for all requests. HTTP and SOCKS proxies are supported. Example: proxy={'server': 'http://proxy.example.com:3128'} | |
| """ # noqa: E501 | |
| color_scheme: Literal["light", "dark", "no-preference"] | None = "no-preference" | |
| java_script_enabled: bool | None = True | |
| viewport: ViewPortModel | None = None | |
| no_viewport: bool | None = False | |
| proxy: dict | None = None | |
| class GetContentModel(BaseModel): | |
| """Webpage to request and parse. | |
| Attributes: | |
| url (HttpUrl): | |
| Url to request. | |
| new_browser (bool | None): | |
| Whether you want to make a new browser context or not. | |
| query_selector (str | None): | |
| Used to locate a selector. | |
| ms_delay (int): | |
| A delay before performing a task after requesting the url. | |
| """ | |
| url: HttpUrl | |
| new_browser: bool | None = False | |
| query_selector: str | None = None | |
| ms_delay: int = Field(default=0.0, ge=0, le=15_000) | |
| class ScreenshotModel(GetContentModel): | |
| """Screenshot schemas | |
| Attributes: | |
| full_page (bool | None): Whether you want a full page screenshot or not. | |
| image_type (Literal["png", "jpeg"]): | |
| The image type of screenshot. | |
| """ | |
| full_page: bool | None = Field( | |
| default = False, | |
| description = "`Whether you want a full page screenshot or not.`") | |
| image_type: Literal["png", "jpeg"] = "jpeg" | |