{"id":20172590,"url":"https://github.com/screenshotone/pythonsdk","last_synced_at":"2025-04-10T02:54:27.496Z","repository":{"id":65016877,"uuid":"580441489","full_name":"screenshotone/pythonsdk","owner":"screenshotone","description":"A Python SDK for ScreenshotOne.com API to take screenshots of URLs, render HTML as images and PDF","archived":false,"fork":false,"pushed_at":"2024-06-12T13:25:51.000Z","size":20,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-10T05:11:01.219Z","etag":null,"topics":["chrome","puppeteer","python","python3","screenshot-utility","screenshots","selenium-python"],"latest_commit_sha":null,"homepage":"https://screenshotone.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/screenshotone.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-20T15:12:48.000Z","updated_at":"2024-08-05T22:44:38.000Z","dependencies_parsed_at":"2024-06-10T13:55:59.078Z","dependency_job_id":null,"html_url":"https://github.com/screenshotone/pythonsdk","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/screenshotone%2Fpythonsdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/screenshotone%2Fpythonsdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/screenshotone%2Fpythonsdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/screenshotone%2Fpythonsdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/screenshotone","download_url":"https://codeload.github.com/screenshotone/pythonsdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224551325,"owners_count":17330124,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chrome","puppeteer","python","python3","screenshot-utility","screenshots","selenium-python"],"created_at":"2024-11-14T01:31:29.061Z","updated_at":"2024-11-14T01:31:37.502Z","avatar_url":"https://github.com/screenshotone.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pythonsdk\n\nAn official Python SDK for [ScreenshotOne.com API](https://screenshotone.com) to take screenshots of URLs, render HTML as images and PDF.\n\nIt takes minutes to start taking screenshots. Just [sign up](https://screenshotone.com/) to get access and secret keys, import the client, and you are ready to go.\n\nThe SDK client is synchronized with the latest [screenshot API options](https://screenshotone.com/docs/options/).\n\n## Installation\n\n```shell\npip install screenshotone\n```\n\n## Usage\n\nGenerate a screenshot URL without executing the request. Or download the screenshot. It is up to you:\n\n```python\nimport shutil\nfrom screenshotone import Client, TakeOptions\n\n# create API client\nclient = Client('\u003cyour access key\u003e', '\u003cyour secret key\u003e')\n\n# set up options\noptions = (TakeOptions.url('https://screenshotone.com')\n    .format(\"png\")\n    .viewport_width(1024)\n    .viewport_height(768)\n    .block_cookie_banners(True)\n    .block_chats(True))\n\n# generate the screenshot URL and share it with a user\nurl = client.generate_take_url(options)\n# expected output: https://api.screenshotone.com/take?url=https%3A%2F%2Fscreenshotone.com\u0026viewport_width=1024\u0026viewport_height=768\u0026block_cookie_banners=True\u0026block_chats=True\u0026access_key=\u003cyour access key\u003e\u0026signature=6afc9417a523788580fa01a9f668ea82c78a9d2b41441d2a696010bf2743170f\n\n# or render a screenshot and download the image as stream\nimage = client.take(options)\n\n# store the screenshot the example.png file\nwith open('example.png', 'wb') as result_file:\n    shutil.copyfileobj(image, result_file)\n```\n\n### How to handle errors\n\nRead about [how to handle the ScreenshotOne API errors](https://screenshotone.com/docs/guides/how-to-handle-api-errors/), and that's how you can get the HTTP status code and the error code of the request:\n\n```python\ntry:\n    # ...\n    # render a screenshot and download the image as stream\n    image = client.take(options)\n    # ...\nexcept InvalidRequestException as e:\n    print(f\"Invalid request: {e}\")\n    if e.http_status_code:\n        print(f\"HTTP Status Code: {e.http_status_code}\")\n    if e.error_code:\n        print(f\"Error Code: {e.error_code}\")\nexcept APIErrorException as e:\n    print(f\"API Error: {e}\")\n    if e.http_status_code:\n        print(f\"HTTP Status Code: {e.http_status_code}\")\n    if e.error_code:\n        print(f\"Error Code: {e.error_code}\")\nexcept Exception as e:\n    # handle any other exceptions\n    print(f\"An unexpected error occurred: {e}\")\n```\n\n## Release\n\n[Github Actions](https://github.com/screenshotone/pythonsdk/blob/main/.github/workflows/pypi-release.yml) is used to automate the release process and publishing to PyPI. Update the library version in `pyproject.toml` and [create a new release](https://github.com/screenshotone/pythonsdk/releases/new) to launch the `publish` workflow.\n\n## License\n\n`screenshotone/pythonsdk` is released under [the MIT license](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscreenshotone%2Fpythonsdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscreenshotone%2Fpythonsdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscreenshotone%2Fpythonsdk/lists"}