Skip to content

Commit 16bcfa7

Browse files
author
Kenneth Reitz
authored
Merge pull request #9 from serpapi/serpapi-client-yield-pages-documentation
Clarify the `serpapi.Client` usage requirement for the `yield_pages` documentation
2 parents 5bdd865 + f0b5661 commit 16bcfa7

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

docs/index.rst

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. serapi-python documentation master file, created by
1+
.. serpapi-python documentation master file, created by
22
sphinx-quickstart on Sun Apr 3 21:09:40 2022.
33
You can adapt this file completely to your liking, but it should at least
44
contain the root `toctree` directive.
@@ -37,6 +37,11 @@ For example, the API endpoint ``https://serpapi.com/search.json`` is represented
3737
3838
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.
3939

40+
.. _using-api-client-directly:
41+
42+
Using the API Client directly
43+
^^^^^^^^^
44+
4045
To make this less repetitive, and gain the benefit of connection pooling, let's start using the API Client directly::
4146

4247
>>> client = serpapi.Client(api_key="secret_api_key")
@@ -116,9 +121,11 @@ You can get the next page of results::
116121
>>> type(s.next_page())
117122
<class 'serpapi.models.SerpResults'>
118123

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>`::
120125

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():
122129
... print(page["search_metadata"]["page_number"])
123130
1
124131
2

0 commit comments

Comments
 (0)