当使用Google Places API的Find Place请求时,如果出现错误消息“不支持的字段名称 'website'”,这意味着您正在尝试在请求中使用不支持的字段名称。
以下是一些解决方法:
以下是一个示例请求,包含不支持的字段名称 'website':
import requests
url = "https://maps.googleapis.com/maps/api/place/findplacefromtext/json"
params = {
"input": "restaurant",
"inputtype": "textquery",
"fields": "name,website", # 'website' 是不支持的字段名称
"key": "YOUR_API_KEY"
}
response = requests.get(url, params=params)
data = response.json()
print(data)
在上面的示例中,字段名称 'website' 是不支持的,因此会出现错误消息。
以下是一个示例请求,更新了字段名称 'website':
import requests
url = "https://maps.googleapis.com/maps/api/place/findplacefromtext/json"
params = {
"input": "restaurant",
"inputtype": "textquery",
"fields": "name", # 更新字段名称,去掉了 'website'
"key": "YOUR_API_KEY"
}
response = requests.get(url, params=params)
data = response.json()
print(data)
在上面的示例中,我们将字段名称 'website' 从请求中移除,以解决错误。
通过确保请求中只包含Google Places API支持的字段名称,您应该能够解决“不支持的字段名称 'website'”的错误。