Skip to content

Commit cf93427

Browse files
authored
Merge pull request #87 from oskarsoderbom/master
Search result number as argument
2 parents 9a617bc + 2fea68b commit cf93427

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ from googlesearch import search
5151
search("Google", sleep_interval=5, num_results=200)
5252
```
5353

54+
```
55+
If requesting more than 10 results, but want to manage the batching yourself?
56+
Use `start_num` to specify the start number of the results you want to get:
57+
```python
58+
from googlesearch import search
59+
search("Google", sleep_interval=5, num_results=200, start_result=10)
60+
```
61+
5462
If you are using a HTTP Rotating Proxy which requires you to install their CA Certificate, you can simply add `ssl_verify=False` in the `search()` method to avoid SSL Verification.
5563
```python
5664
from googlesearch import search

googlesearch/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ def __init__(self, url, title, description):
3636
def __repr__(self):
3737
return f"SearchResult(url={self.url}, title={self.title}, description={self.description})"
3838

39-
def search(term, num_results=10, lang="en", proxy=None, advanced=False, sleep_interval=0, timeout=5, safe="active", ssl_verify=None, region=None):
39+
40+
def search(term, num_results=10, lang="en", proxy=None, advanced=False, sleep_interval=0, timeout=5, safe="active", ssl_verify=None, region=None, start_num=0):
4041
"""Search the Google search engine"""
4142

4243
# Proxy setup
4344
proxies = {"https": proxy, "http": proxy} if proxy and (proxy.startswith("https") or proxy.startswith("http")) else None
4445

45-
start = 0
46+
start = start_num
4647
fetched_results = 0 # Keep track of the total fetched results
4748

4849
while fetched_results < num_results:

0 commit comments

Comments
 (0)