|
1 | | -.. serapi-python documentation master file, created by |
| 1 | +.. serpapi-python documentation master file, created by |
2 | 2 | sphinx-quickstart on Sun Apr 3 21:09:40 2022. |
3 | 3 | You can adapt this file completely to your liking, but it should at least |
4 | 4 | contain the root `toctree` directive. |
@@ -37,6 +37,11 @@ For example, the API endpoint ``https://serpapi.com/search.json`` is represented |
37 | 37 |
|
38 | 38 | Any parameters that you pass to ``search()`` will be passed to the API. This includes the ``api_key`` parameter, which is required for all requests. |
39 | 39 |
|
| 40 | +.. _using-api-client-directly: |
| 41 | + |
| 42 | +Using the API Client directly |
| 43 | +^^^^^^^^^ |
| 44 | + |
40 | 45 | To make this less repetitive, and gain the benefit of connection pooling, let's start using the API Client directly:: |
41 | 46 |
|
42 | 47 | >>> client = serpapi.Client(api_key="secret_api_key") |
@@ -116,9 +121,11 @@ You can get the next page of results:: |
116 | 121 | >>> type(s.next_page()) |
117 | 122 | <class 'serpapi.models.SerpResults'> |
118 | 123 |
|
119 | | -Or iterate over all pages of results:: |
| 124 | +To iterate over all pages of results, it's recommended to :ref:`use the API Client directly <using-api-client-directly>`:: |
120 | 125 |
|
121 | | - >>> for page in s.yield_pages(): |
| 126 | + >>> client = serpapi.Client(api_key="secret_api_key") |
| 127 | + >>> search = client.search(q="Coffee", engine="google", location="Austin, Texas", hl="en", gl="us") |
| 128 | + >>> for page in search.yield_pages(): |
122 | 129 | ... print(page["search_metadata"]["page_number"]) |
123 | 130 | 1 |
124 | 131 | 2 |
|
0 commit comments