Skip to content

Commit 6afb5eb

Browse files
committed
fix to_dict options method: do not add key when list is empty
1 parent 1c8c613 commit 6afb5eb

File tree

4 files changed

+70
-4
lines changed

4 files changed

+70
-4
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
python-version: ["3.9", "3.10", "3.11"]
15+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
1616

1717
steps:
1818
- uses: actions/checkout@v4

README.md

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,79 @@ Get started in minutes. Just [sign up](https://screenshotmax.com) to receive you
1111

1212
The SDK client is synchronized with the latest [ScreenshotMAX API options](https://docs.screenshotmax.com/guides/start/introduction).
1313

14+
## Usage
1415

16+
Use the SDK to generate signed or unsigned URLs for screenshots, PDFs, web scraping, or animated screenshot—without executing the request. Or fetch and download the result directly. You have full control over when and how each capture runs.
17+
18+
### Screenshot example
1519
```python
16-
from python_sdk import SDK
17-
from python_sdk.options import ScreenshotOptions
20+
from screenshotmax import SDK
21+
from screenshotmax.options import ScreenshotOptions
1822

1923
sdk = SDK("<ACCESS_KEY>", "<SECRET_KEY>")
2024

25+
# set up options
2126
opts = ScreenshotOptions(url="https://example.com")
2227
sdk.screenshot.set_options(opts)
28+
29+
#// generate URL (https://api.screenshotmax.com/v1/screenshot?url=https%3A%2F%2Fexample.com&image_width=1280&image_height=720&format=png&image_quality=80&access_key=<ACCESS_KEY>&signature=370f5b161bc59eed13b76........1f778635d7fc595dbab12)
2330
url = sdk.screenshot.get_url()
31+
32+
# generate screenshot
2433
result, headers = sdk.screenshot.fetch()
2534
```
35+
36+
### Web scraping example
37+
```python
38+
from screenshotmax import SDK
39+
from screenshotmax.options import ScrapeOptions
40+
41+
sdk = SDK("<ACCESS_KEY>", "<SECRET_KEY>")
42+
43+
# set up options and scrape content (chaining)
44+
opts = ScrapeOptions(url="https://example.com")
45+
sdk.scrape.set_options(opts)
46+
47+
result, headers = sdk.scrape.fetch()
48+
```
49+
50+
### PDF generation example
51+
```python
52+
from screenshotmax import SDK
53+
from screenshotmax.enums import PDFPaperFormat
54+
from screenshotmax.options import PDFOptions
55+
56+
sdk = SDK("<ACCESS_KEY>", "<SECRET_KEY>")
57+
58+
# set up options and scrape content (chaining)
59+
opts = PDFOptions(url="https://example.com", pdf_paper_format=PDFPaperFormat.LETTER)
60+
result, headers = sdk.pdf.set_options(opts).fetch()
61+
```
62+
63+
### Scheduled task example
64+
```python
65+
from screenshotmax import SDK
66+
from screenshotmax.options import PDFOptions
67+
68+
sdk = SDK("<ACCESS_KEY>", "<SECRET_KEY>")
69+
70+
# get all tasks from account
71+
tasks = sdk.task.get_tasks()
72+
# {"tasks":[{
73+
# "id":5678133109850112,
74+
# "name":"Test CRON",
75+
# "api":"screenshot",
76+
# "query":
77+
# "url=https%3A%2F%2Fexample.com",
78+
# "frequency":"every_day",
79+
# "crontab":"25 13 * * *",
80+
# "timezone":"Etc/UTC",
81+
# "enabled":true,
82+
# "created":1747229104,
83+
# "last_run":1748611516,
84+
# "runs":18}]}
85+
```
86+
87+
## License
88+
89+
`screenshotmax` is released under [the MIT license](LICENSE).

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "screenshotmax"
7-
version = "1.0.0"
7+
version = "1.0.1"
88
description = "Official Python SDK for ScreenshotMAX API"
99
readme = "README.md"
1010
requires-python = ">=3.7"

src/screenshotmax/options.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ def to_dict(self) -> Dict[str, Any]:
6969
for k, v in data.items():
7070
if v is None:
7171
continue
72+
if isinstance(v, list) and len(v) == 0:
73+
continue
7274
if isinstance(v, Enum):
7375
result[k] = v.value
7476
elif isinstance(v, list) and v and isinstance(v[0], Enum):

0 commit comments

Comments
 (0)