Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zytedata/python-zyte-api
Python client for Zyte API
https://github.com/zytedata/python-zyte-api
hacktoberfest
Last synced: about 2 months ago
JSON representation
Python client for Zyte API
- Host: GitHub
- URL: https://github.com/zytedata/python-zyte-api
- Owner: zytedata
- License: bsd-3-clause
- Created: 2021-08-20T20:12:14.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-29T05:47:53.000Z (7 months ago)
- Last Synced: 2024-05-29T06:31:54.181Z (7 months ago)
- Topics: hacktoberfest
- Language: Python
- Homepage:
- Size: 608 KB
- Stars: 17
- Watchers: 14
- Forks: 4
- Open Issues: 8
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGES.rst
- Contributing: docs/contributing.rst
- License: LICENSE
Awesome Lists containing this project
README
===============
python-zyte-api
===============.. image:: https://img.shields.io/pypi/v/zyte-api.svg
:target: https://pypi.python.org/pypi/zyte-api
:alt: PyPI Version.. image:: https://img.shields.io/pypi/pyversions/zyte-api.svg
:target: https://pypi.python.org/pypi/zyte-api
:alt: Supported Python Versions.. image:: https://github.com/zytedata/python-zyte-api/actions/workflows/test.yml/badge.svg
:target: https://github.com/zytedata/python-zyte-api/actions/workflows/test.yml
:alt: Build Status.. image:: https://codecov.io/github/zytedata/zyte-api/coverage.svg?branch=master
:target: https://codecov.io/gh/zytedata/zyte-api
:alt: Coverage report.. description-start
Command-line client and Python client library for `Zyte API`_.
.. _Zyte API: https://docs.zyte.com/zyte-api/get-started.html
.. description-end
Installation
============.. install-start
.. code-block:: shell
pip install zyte-api
.. note:: Python 3.9+ is required.
.. install-end
Basic usage
===========.. basic-start
Set your API key
----------------.. key-get-start
After you `sign up for a Zyte API account
`_, copy `your API key
`_... key-get-end
Use the command-line client
---------------------------Then you can use the zyte-api command-line client to send Zyte API requests.
First create a text file with a list of URLs:.. code-block:: none
https://books.toscrape.com
https://quotes.toscrape.comAnd then call ``zyte-api`` from your shell:
.. code-block:: shell
zyte-api url-list.txt --api-key YOUR_API_KEY --output results.jsonl
Use the Python sync API
-----------------------For very basic Python scripts, use the sync API:
.. code-block:: python
from zyte_api import ZyteAPI
client = ZyteAPI(api_key="YOUR_API_KEY")
response = client.get({"url": "https://toscrape.com", "httpResponseBody": True})Use the Python async API
------------------------For asyncio code, use the async API:
.. code-block:: python
import asyncio
from zyte_api import AsyncZyteAPI
async def main():
client = AsyncZyteAPI(api_key="YOUR_API_KEY")
response = await client.get(
{"url": "https://toscrape.com", "httpResponseBody": True}
)asyncio.run(main())
.. basic-end
Read the `documentation `_ for more
information.* Documentation: https://python-zyte-api.readthedocs.io
* Source code: https://github.com/zytedata/python-zyte-api
* Issue tracker: https://github.com/zytedata/python-zyte-api/issues