可以用来查询旅游地的美食,酒店,洗手间,商场,景点等
import requests
# Define the API key
api_key = "YOUR_API_KEY"
# Define a function to search for places
def search_places(location, category):
url = "https://maps.googleapis.com/maps/api/place/textsearch/json?query={}+{}&key={}".format(location, category, api_key)
response = requests.get(url)
data = response.json()
return data["results"]
# Get the destination from the user
destination = input("请输入你的旅游目的地:")
# Get the type of place from the user
place_type = input("请输入你想查询的地方类型(如酒店,美食,景点等):")
# Search for places
places = search_places(destination, place_type)
# Print the results
print("我们为您找到了这些地方:")
for place in places:
print(place["name"])