Untitled
user_3839718
python
03/09/2024 8:19 PM
1.5 KB
14
Indexable
from googleplaces import types
from place.app import PlaceSearch
from review.app import crawl_review
import os
from db.app import ES
import json
param = dict(lat_lng={'lat': 41.38257847415095,
'lng': 2.176434738505483},
radius=500,
types=[types.TYPE_BAR])
# generate name using lat and lng and radius
name = f"{param['lat_lng']['lat']}_{param['lat_lng']['lng']}_{param['radius']}"
# get project root path
data_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "data")
place_data_path = os.path.join(data_path, "{}_places.json".format(name))
reviewed_total_data_path = os.path.join(data_path, "{}_with_review.json".format(name))
PlaceSearch(param=param, saved_path=place_data_path).run()
crawl_review(place_data_path=place_data_path, saved_reviewed_path=reviewed_total_data_path)
es = ES(container_es_host="3.123.37.58:9200",
container_es_user="elastic",
container_es_password="F4R0M4T1ks!Scout_")
with open("{}_with_review.json".format(name), "r") as f:
data = json.load(f)
for item in data:
es.save(index_name="review", document_id=item["place_id"], doc=item)Editor is loading...
Leave a Comment