Spaces:
Sleeping
Sleeping
Update app/core/service/playwright/models.py
Browse files
app/core/service/playwright/models.py
CHANGED
@@ -6,19 +6,64 @@ from pydantic import BaseModel, Field, HttpUrl
|
|
6 |
|
7 |
|
8 |
class ViewPortModel(BaseModel):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
width: int = 1280
|
10 |
height: int = 720
|
11 |
|
12 |
|
13 |
class PageModel(BaseModel):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
color_scheme: Literal["light", "dark", "no-preference"] | None = "no-preference"
|
15 |
java_script_enabled: bool | None = True
|
16 |
viewport: ViewPortModel | None = None
|
17 |
-
proxy: dict | None = None
|
18 |
no_viewport: bool | None = False
|
|
|
19 |
|
20 |
|
21 |
class GetContentModel(BaseModel):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
url: HttpUrl
|
23 |
new_browser: bool | None = False
|
24 |
query_selector: str | None = None
|
@@ -26,6 +71,16 @@ class GetContentModel(BaseModel):
|
|
26 |
|
27 |
|
28 |
class ScreenshotModel(GetContentModel):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
full_page: bool | None = False
|
30 |
image_type: Literal["png", "jpeg"] = "jpeg"
|
31 |
|
|
|
6 |
|
7 |
|
8 |
class ViewPortModel(BaseModel):
|
9 |
+
"""Page viewport
|
10 |
+
|
11 |
+
Attributes:
|
12 |
+
width (int):
|
13 |
+
viewport width.
|
14 |
+
|
15 |
+
height (int):
|
16 |
+
viewport height.
|
17 |
+
"""
|
18 |
+
|
19 |
width: int = 1280
|
20 |
height: int = 720
|
21 |
|
22 |
|
23 |
class PageModel(BaseModel):
|
24 |
+
"""Page attrs
|
25 |
+
|
26 |
+
Attributes:
|
27 |
+
color_scheme (Literal["light", "dark", "no-preference"] | None):
|
28 |
+
Page color.
|
29 |
+
|
30 |
+
java_script_enabled (bool | None):
|
31 |
+
Whether or not to enable JavaScript in the context. Defaults to true.
|
32 |
+
|
33 |
+
viewport (ViewPortModel | None):
|
34 |
+
Sets a consistent viewport for each page. Defaults to an 1280x720 viewport.
|
35 |
+
|
36 |
+
no_viewport (bool | None):
|
37 |
+
Does not enforce fixed viewport, allows resizing window in the headed mode.
|
38 |
+
|
39 |
+
proxy (dict | None):
|
40 |
+
Proxy to be used for all requests. HTTP and SOCKS proxies are supported. Example: proxy={'server': 'http://proxy.example.com:3128'}
|
41 |
+
""" # noqa: E501
|
42 |
+
|
43 |
color_scheme: Literal["light", "dark", "no-preference"] | None = "no-preference"
|
44 |
java_script_enabled: bool | None = True
|
45 |
viewport: ViewPortModel | None = None
|
|
|
46 |
no_viewport: bool | None = False
|
47 |
+
proxy: dict | None = None
|
48 |
|
49 |
|
50 |
class GetContentModel(BaseModel):
|
51 |
+
"""Webpage to request and parse.
|
52 |
+
|
53 |
+
Attributes:
|
54 |
+
url (HttpUrl):
|
55 |
+
Url to request.
|
56 |
+
|
57 |
+
new_browser (bool | None):
|
58 |
+
Whether you want to make a new browser context or not.
|
59 |
+
|
60 |
+
query_selector (str | None):
|
61 |
+
Used to locate a selector.
|
62 |
+
|
63 |
+
ms_delay (int):
|
64 |
+
A delay before performing a task after requesting the url.
|
65 |
+
"""
|
66 |
+
|
67 |
url: HttpUrl
|
68 |
new_browser: bool | None = False
|
69 |
query_selector: str | None = None
|
|
|
71 |
|
72 |
|
73 |
class ScreenshotModel(GetContentModel):
|
74 |
+
"""Screenshot schemas
|
75 |
+
|
76 |
+
Attributes:
|
77 |
+
full_page (bool | None):
|
78 |
+
Whether you want a full page screenshot or not.
|
79 |
+
|
80 |
+
image_type (Literal["png", "jpeg"]):
|
81 |
+
The image type of screenshot.
|
82 |
+
"""
|
83 |
+
|
84 |
full_page: bool | None = False
|
85 |
image_type: Literal["png", "jpeg"] = "jpeg"
|
86 |
|