Skip to content

Commit d52bfad

Browse files
author
vlad-outscraper
committed
2 parents b89a1b4 + 7880481 commit d52bfad

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Run Requests to Outscraper API in Parallel
2+
3+
The example shows how to create multiple requests to Outscraper API in parallel to increase the execution time.
4+
5+
## Installation
6+
7+
Python 3+
8+
```bash
9+
pip install outscraper
10+
```
11+
[Link to the Python package page](https://pypi.org/project/outscraper/)
12+
13+
## Initialization
14+
```python
15+
from functools import partial
16+
from multiprocessing.pool import ThreadPool
17+
18+
from outscraper import ApiClient
19+
20+
21+
client = ApiClient(api_key='SECRET_API_KEY')
22+
```
23+
[Link to the profile page to create the API key](https://app.outscraper.com/profile)
24+
25+
## Usage
26+
27+
```python
28+
place_ids = [
29+
'ChIJNw4_-cWXyFYRF_4GTtujVsw',
30+
'ChIJ39fGAcGXyFYRNdHIXy-W5BA',
31+
'ChIJVVVl-cWXyFYRQYBCEkX0W5Y',
32+
'ChIJScUP1R6XyFYR0sY1UwNzq-c',
33+
'ChIJmeiNBMeXyFYRzQrnMMDV8Jc',
34+
'ChIJifOTBMeXyFYRmu3EGp_QBuY',
35+
'ChIJ1fwt-cWXyFYR2cjoDAGs9UI',
36+
'ChIJ5zQrTzSXyFYRuiY31iE7M1s',
37+
'ChIJQSyf4huXyFYRpP9W4rtBelA',
38+
'ChIJRWK5W2-byFYRiaF9vVgzZA4'
39+
]
40+
41+
pool = ThreadPool(4) # number of threads, use something between 2 and 40
42+
results = pool.map(partial(client.google_maps_search_v2, language='en', region='US'), place_ids)
43+
```

0 commit comments

Comments
 (0)