You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Google Places API按用户评价总数及评分筛选结果?

解决Google Places API筛选评价数与评分的问题

首先明确:Google Places Nearby Search API不支持直接通过user_ratings_total或rating参数在请求阶段筛选结果,你之前的请求里加user_ratings_total=15000是无效的,因为这个参数不属于Nearby Search的请求参数列表。

要实现筛选「用户评价总数超过1000且评分为4.5」的餐厅,需要分两步操作:

1. 发起基础Nearby Search请求

先获取目标区域内的餐厅列表,请求只保留必要参数:

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=24.7588310%2C46.7330426&radius=10500&type=restaurant&key=YOUR_GOOGLE_API_KEY

这个请求会返回该区域内的餐厅数据,每条结果会包含user_ratings_total(评价总数)和rating(评分)字段。

2. 二次筛选结果

拿到API返回的JSON数据后,在你的代码里手动过滤符合条件的条目。

示例:JavaScript筛选逻辑

// 假设apiResponse是API返回的完整数据
const filteredRestaurants = apiResponse.results.filter(place => {
  return place.user_ratings_total > 1000 && place.rating === 4.5;
});

示例:Python筛选逻辑

# 假设api_response是API返回的字典
filtered_restaurants = [
    place for place in api_response['results']
    if place.get('user_ratings_total', 0) > 1000 and place.get('rating', 0) == 4.5
]

补充说明

如果目标区域内餐厅数量多(超过Nearby Search的单页返回上限20条),你需要处理分页(用next_page_token参数获取下一页数据),再对所有页的结果统一做筛选。

内容的提问来源于stack exchange,提问作者khalid Saud

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.13 11:55:36