您也可以在没有浏览器自动化的情况下获得所有评论。
您只需要data_id(看起来像这样:0x133b0841ef6e38e5:0xece6ea09987e9baf,您可以从您发布的地图网址中获取)
之后,您只需发送请求至:https://www.google.com/async/reviewDialog?hl=en&async=feature_id:0x133b0841ef6e38e5:0xece6ea09987e9baf,sort_by:,next_page_token:,associated_topic:,_fmt:pc
在那里你会找到所有的评论数据,以及next_page_token,所以你可以查询接下来的10条评论。
在这种情况下,next_page_token 是:EgIICg
因此,接下来 10 条评论的请求 URL 将是:https://www.google.com/async/reviewDialog?hl=en&async=feature_id:0x133b0841ef6e38e5:0xece6ea09987e9baf,sort_by:,next_page_token:EgIICg,associated_topic:,_fmt:pc
您还可以使用 SerpApi 等第三方解决方案。这是一个免费试用的付费 API。我们为您处理代理、解决验证码并解析所有丰富的结构化数据。
示例 python 代码(其他库中也有):
from serpapi import GoogleSearch
params = {
"api_key": "secret_api_key",
"engine": "google_maps_reviews",
"hl": "en",
"data_id": "0x133b0841ef6e38e5:0xece6ea09987e9baf",
}
search = GoogleSearch(params)
results = search.get_dict()
JSON 输出示例:
"place_info": {
"title": "Pizzeria Di Matteo",
"address": "Via dei Tribunali, 94, Napoli NA, Italy",
"rating": 4.4,
"reviews": 7082
},
"reviews": [
{
"user": {
"name": "Thomas Bichler",
"link": "https://www.google.com/maps/contrib/117092186939269423235?hl=en-US&sa=X&ved=2ahUKEwifo9yvmODxAhWHY98KHSDtAakQvvQBegQIARAw",
"thumbnail": "https://lh3.googleusercontent.com/a-/AOh14GjDBVeLxUSBqv4WKvPuVqMbpZ5cdDfjyTlcSxTgQKw=s40-c-c0x00000000-cc-rp-mo-ba4-br100",
"local_guide": true,
"reviews": 164,
"photos": 88
},
"rating": 5,
"date": "a week ago",
"snippet": "Great Pizza Fritta! Although the place looks only like a take-away from the outside there is plenty of seating places in the back and upstairs. Don't be afraid to pass by the deep-fryer and make your way to the back. The Pizza Fritta we had easily serves two for lunch. We ordered one per person and couldn't finish it.Nothing fancy here and that's good. Everything is focuessed on the food!",
"images": [
"https://lh5.googleusercontent.com/p/AF1QipO0xuP-Fbq1R88lr4ecedPcV6I34uIxqW6tro_m=w100-h100-p-n-k-no"
]
},
{
"user": {
"name": "Andrea Caruso",
"link": "https://www.google.com/maps/contrib/103428787808835823312?hl=en-US&sa=X&ved=2ahUKEwifo9yvmODxAhWHY98KHSDtAakQvvQBegQIARA_",
"thumbnail": "https://lh3.googleusercontent.com/a-/AOh14GgYfhxg1E5DZJJ8YJtjTS5lbhYrQ5ekpbak4VKAtg4=s40-c-c0x00000000-cc-rp-mo-ba5-br100",
"local_guide": true,
"reviews": 290,
"photos": 15
},
"rating": 5,
"date": "6 days ago",
"snippet": "Classic Italian pizza and one of the best ones!I really liked the Margherita and the melanzane.Slightly disappointed by the sausage in the salsiccia and friarielli.Friendly staff and fast service",
"images": [
"https://lh5.googleusercontent.com/p/AF1QipOw0-2R5bGQ6NVTimGHOOJjUtBvf5phfA0PYtpe=w100-h100-p-n-k-no",
"https://lh5.googleusercontent.com/p/AF1QipM2UUdwNMZnogt2DMptnQsfiFmP_b5mgQPhXlUn=w100-h100-p-n-k-no",
"https://lh5.googleusercontent.com/p/AF1QipPaFQYhx5Z2nM0AxDWus52R0xK-5KJP6ZQuEHJU=w100-h100-p-n-k-no"
]
},
{
"user": {
"name": "asia rizzoli",
"link": "https://www.google.com/maps/contrib/106734226225183718730?hl=en-US&sa=X&ved=2ahUKEwifo9yvmODxAhWHY98KHSDtAakQvvQBegQIARBQ",
"thumbnail": "https://lh3.googleusercontent.com/a-/AOh14GhiFJr7dFNeo6Y85fCdmMYyaOLl-2YZSPzVTQj83A=s40-c-c0x00000000-cc-rp-mo-ba4-br100",
"local_guide": true,
"reviews": 69,
"photos": 111
},
"rating": 4,
"date": "3 weeks ago",
"snippet": "We tried the ‘frittura’ ‘fried street food’ outside the restaurant entrance. The ‘frittata di pasta’ (fried pasta) was Amazing! I totally fell in love with it. The ‘crocché’ (fried mashed patatos) was also good, although nothing special. We did not like the arancini a lot.. but on a balance it is worth a try!",
"images": [
"https://lh5.googleusercontent.com/p/AF1QipMamXnfHbILMA5y_6v5qHkXjoDM3_i9hwllAwn8=w100-h100-p-n-k-no",
"https://lh5.googleusercontent.com/p/AF1QipMwpZ2dqLYnwg2KePI46Qfnk46vDzhXJwCkCjn3=w100-h100-p-n-k-no",
"https://lh5.googleusercontent.com/p/AF1QipOwfcwtQIDMUq1M4Qcg54mqrIg1fUWnDZkXfDhr=w100-h100-p-n-k-no",
"https://lh5.googleusercontent.com/p/AF1QipO6I7EgACHnh8UJbfi6H_43m1bPJ4hefqGBn7Zz=w100-h100-p-n-k-no",
"https://lh5.googleusercontent.com/p/AF1QipMlLbFU0AaGKkvlLymTX9eTJEDlS881TMvE6Lvk=w100-h100-p-n-k-no",
"https://lh5.googleusercontent.com/p/AF1QipNhhzjpiaxCFE4LCAhXGYAT-jz8dsn-S1SDtsWy=w100-h100-p-n-k-no"
]
},
...
]
查看documentation了解更多详情。
免责声明:我在 SerpApi 工作。