snaprender 0.2.3__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {snaprender-0.2.3 → snaprender-0.3.0}/.gitignore +1 -2
- {snaprender-0.2.3 → snaprender-0.3.0}/PKG-INFO +5 -5
- {snaprender-0.2.3 → snaprender-0.3.0}/README.md +4 -4
- {snaprender-0.2.3 → snaprender-0.3.0}/pyproject.toml +1 -1
- {snaprender-0.2.3 → snaprender-0.3.0}/snaprender/__init__.py +1 -1
- {snaprender-0.2.3 → snaprender-0.3.0}/snaprender/client.py +88 -35
- {snaprender-0.2.3 → snaprender-0.3.0}/LICENSE +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: snaprender
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Official Python SDK for SnapRender Screenshot API
|
|
5
5
|
Project-URL: Homepage, https://snap-render.com
|
|
6
6
|
Project-URL: Documentation, https://snap-render.com/docs
|
|
@@ -20,7 +20,7 @@ Description-Content-Type: text/markdown
|
|
|
20
20
|
|
|
21
21
|
Official Python SDK for the [SnapRender](https://snap-render.com) Screenshot API — capture pixel-perfect screenshots of any webpage with a single API call.
|
|
22
22
|
|
|
23
|
-
**
|
|
23
|
+
**500 free screenshots/month — [Get your API key](https://snap-render.com/auth/signup?ref=pypi)**
|
|
24
24
|
|
|
25
25
|
## Features
|
|
26
26
|
|
|
@@ -155,10 +155,10 @@ except SnapRenderError as e:
|
|
|
155
155
|
|
|
156
156
|
## Links
|
|
157
157
|
|
|
158
|
-
- [Documentation](https://
|
|
159
|
-
- [Pricing](https://
|
|
158
|
+
- [Documentation](https://snap-render.com/docs)
|
|
159
|
+
- [Pricing](https://snap-render.com/pricing)
|
|
160
160
|
- [Dashboard](https://app.snap-render.com/dashboard)
|
|
161
|
-
- [Blog](https://
|
|
161
|
+
- [Blog](https://snap-render.com/blog)
|
|
162
162
|
- [GitHub](https://github.com/User0856/snaprender)
|
|
163
163
|
|
|
164
164
|
## License
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
Official Python SDK for the [SnapRender](https://snap-render.com) Screenshot API — capture pixel-perfect screenshots of any webpage with a single API call.
|
|
8
8
|
|
|
9
|
-
**
|
|
9
|
+
**500 free screenshots/month — [Get your API key](https://snap-render.com/auth/signup?ref=pypi)**
|
|
10
10
|
|
|
11
11
|
## Features
|
|
12
12
|
|
|
@@ -141,10 +141,10 @@ except SnapRenderError as e:
|
|
|
141
141
|
|
|
142
142
|
## Links
|
|
143
143
|
|
|
144
|
-
- [Documentation](https://
|
|
145
|
-
- [Pricing](https://
|
|
144
|
+
- [Documentation](https://snap-render.com/docs)
|
|
145
|
+
- [Pricing](https://snap-render.com/pricing)
|
|
146
146
|
- [Dashboard](https://app.snap-render.com/dashboard)
|
|
147
|
-
- [Blog](https://
|
|
147
|
+
- [Blog](https://snap-render.com/blog)
|
|
148
148
|
- [GitHub](https://github.com/User0856/snaprender)
|
|
149
149
|
|
|
150
150
|
## License
|
|
@@ -44,8 +44,10 @@ class SnapRender:
|
|
|
44
44
|
|
|
45
45
|
def capture(
|
|
46
46
|
self,
|
|
47
|
-
url: str,
|
|
47
|
+
url: Optional[str] = None,
|
|
48
48
|
*,
|
|
49
|
+
html: Optional[str] = None,
|
|
50
|
+
markdown: Optional[str] = None,
|
|
49
51
|
format: str = "png",
|
|
50
52
|
width: Optional[int] = None,
|
|
51
53
|
height: Optional[int] = None,
|
|
@@ -63,40 +65,91 @@ class SnapRender:
|
|
|
63
65
|
cache_ttl: Optional[int] = None,
|
|
64
66
|
response_type: Optional[str] = None,
|
|
65
67
|
) -> "bytes | dict[str, Any]":
|
|
66
|
-
"""Capture a screenshot.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
68
|
+
"""Capture a screenshot. Provide exactly one of: url, html, or markdown.
|
|
69
|
+
|
|
70
|
+
When html or markdown is provided, uses POST with JSON body.
|
|
71
|
+
When url is provided, uses GET with query parameters (backward compatible).
|
|
72
|
+
Returns bytes by default, or a dict when response_type='json'.
|
|
73
|
+
"""
|
|
74
|
+
use_post = bool(html or markdown)
|
|
75
|
+
|
|
76
|
+
if use_post:
|
|
77
|
+
body: dict[str, Any] = {"format": format}
|
|
78
|
+
if url is not None:
|
|
79
|
+
body["url"] = url
|
|
80
|
+
if html is not None:
|
|
81
|
+
body["html"] = html
|
|
82
|
+
if markdown is not None:
|
|
83
|
+
body["markdown"] = markdown
|
|
84
|
+
if width is not None:
|
|
85
|
+
body["width"] = width
|
|
86
|
+
if height is not None:
|
|
87
|
+
body["height"] = height
|
|
88
|
+
if full_page is not None:
|
|
89
|
+
body["full_page"] = full_page
|
|
90
|
+
if quality is not None:
|
|
91
|
+
body["quality"] = quality
|
|
92
|
+
if delay is not None:
|
|
93
|
+
body["delay"] = delay
|
|
94
|
+
if dark_mode is not None:
|
|
95
|
+
body["dark_mode"] = dark_mode
|
|
96
|
+
if block_ads is not None:
|
|
97
|
+
body["block_ads"] = block_ads
|
|
98
|
+
if block_cookie_banners is not None:
|
|
99
|
+
body["block_cookie_banners"] = block_cookie_banners
|
|
100
|
+
if hide_selectors is not None:
|
|
101
|
+
body["hide_selectors"] = hide_selectors
|
|
102
|
+
if click_selector is not None:
|
|
103
|
+
body["click_selector"] = click_selector
|
|
104
|
+
if device is not None:
|
|
105
|
+
body["device"] = device
|
|
106
|
+
if user_agent is not None:
|
|
107
|
+
body["user_agent"] = user_agent
|
|
108
|
+
if cache is not None:
|
|
109
|
+
body["cache"] = cache
|
|
110
|
+
if cache_ttl is not None:
|
|
111
|
+
body["cache_ttl"] = cache_ttl
|
|
112
|
+
if response_type is not None:
|
|
113
|
+
body["response_type"] = response_type
|
|
114
|
+
|
|
115
|
+
resp = self._client.post("/v1/screenshot", json=body)
|
|
116
|
+
else:
|
|
117
|
+
if not url:
|
|
118
|
+
raise ValueError("One of url, html, or markdown is required")
|
|
119
|
+
params: dict[str, Any] = {"url": url, "format": format}
|
|
120
|
+
if width is not None:
|
|
121
|
+
params["width"] = width
|
|
122
|
+
if height is not None:
|
|
123
|
+
params["height"] = height
|
|
124
|
+
if full_page is not None:
|
|
125
|
+
params["full_page"] = str(full_page).lower()
|
|
126
|
+
if quality is not None:
|
|
127
|
+
params["quality"] = quality
|
|
128
|
+
if delay is not None:
|
|
129
|
+
params["delay"] = delay
|
|
130
|
+
if dark_mode is not None:
|
|
131
|
+
params["dark_mode"] = str(dark_mode).lower()
|
|
132
|
+
if block_ads is not None:
|
|
133
|
+
params["block_ads"] = str(block_ads).lower()
|
|
134
|
+
if block_cookie_banners is not None:
|
|
135
|
+
params["block_cookie_banners"] = str(block_cookie_banners).lower()
|
|
136
|
+
if hide_selectors is not None:
|
|
137
|
+
params["hide_selectors"] = hide_selectors
|
|
138
|
+
if click_selector is not None:
|
|
139
|
+
params["click_selector"] = click_selector
|
|
140
|
+
if device is not None:
|
|
141
|
+
params["device"] = device
|
|
142
|
+
if user_agent is not None:
|
|
143
|
+
params["user_agent"] = user_agent
|
|
144
|
+
if cache is not None:
|
|
145
|
+
params["cache"] = str(cache).lower()
|
|
146
|
+
if cache_ttl is not None:
|
|
147
|
+
params["cache_ttl"] = cache_ttl
|
|
148
|
+
if response_type is not None:
|
|
149
|
+
params["response_type"] = response_type
|
|
150
|
+
|
|
151
|
+
resp = self._client.get("/v1/screenshot", params=params)
|
|
152
|
+
|
|
100
153
|
if resp.status_code != 200:
|
|
101
154
|
self._raise_error(resp)
|
|
102
155
|
if response_type == "json":
|
|
File without changes
|