Skip to content

Commit 64b173e

Browse files
authored
Update README.md
1 parent 2dca65d commit 64b173e

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

examples/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,35 @@ import pandas as pd
103103
df = pd.DataFrame(all_places)
104104
df.to_csv('results.csv', index=None)
105105
```
106+
107+
## Example 6: Get Places Information From a list of Place IDs (Multithreading)
108+
109+
```python
110+
from functools import partial
111+
from multiprocessing.pool import ThreadPool
112+
113+
place_ids = [
114+
'ChIJNw4_-cWXyFYRF_4GTtujVsw',
115+
'ChIJ39fGAcGXyFYRNdHIXy-W5BA',
116+
'ChIJVVVl-cWXyFYRQYBCEkX0W5Y',
117+
'ChIJScUP1R6XyFYR0sY1UwNzq-c',
118+
'ChIJmeiNBMeXyFYRzQrnMMDV8Jc',
119+
'ChIJifOTBMeXyFYRmu3EGp_QBuY',
120+
'ChIJ1fwt-cWXyFYR2cjoDAGs9UI',
121+
'ChIJ5zQrTzSXyFYRuiY31iE7M1s',
122+
'ChIJQSyf4huXyFYRpP9W4rtBelA',
123+
'ChIJRWK5W2-byFYRiaF9vVgzZA4'
124+
]
125+
126+
# fast download in 4 threads
127+
pool = ThreadPool(4)
128+
results = pool.map(partial(api_client.google_maps_search_v2, limit=500, language='en', region='US'), place_ids)
129+
130+
# combine places from all queries
131+
all_places = []
132+
for query_places in results:
133+
if query_places and query_places[0]:
134+
all_places.append(query_places[0][0])
135+
else:
136+
all_places.append({})
137+
```

0 commit comments

Comments
 (0)