File size: 2,340 Bytes
de68d43
 
 
 
fccdd05
de68d43
 
 
7db94d4
 
 
 
 
 
 
 
 
 
de68d43
 
 
 
 
7db94d4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
de68d43
 
 
 
7db94d4
de68d43
 
 
7db94d4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
de68d43
1532ef0
de68d43
efd4911
de68d43
 
 
7db94d4
 
 
0080981
c739443
0080981
7db94d4
 
 
 
0080981
 
 
efd4911
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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"