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

如何编写Google Sheets的IMPORTXML获取TripAdvisor评论与评分?

解决Google Sheets IMPORTXML抓取TripAdvisor酒店评分与评论数的XPath问题

TripAdvisor页面结构会动态更新,你使用的绝对路径XPath过于依赖固定层级,极易失效。以下是基于元素特征属性的稳定XPath写法:

抓取酒店评分(如4.5/5)

获取纯评分数值(如4.5)

=IMPORTXML("https://www.tripadvisor.com/Hotel_Review-g57653-d15065834-Reviews-Hampton_Inn_Suites_Culpeper-Culpeper_Virginia.html","//div[@data-test-target='review-rating']/span","en_US")

获取完整评分格式(如4.5/5)

=IMPORTXML("https://www.tripadvisor.com/Hotel_Review-g57653-d15065834-Reviews-Hampton_Inn_Suites_Culpeper-Culpeper_Virginia.html","//div[@data-test-target='review-rating']/following-sibling::span","en_US")

抓取评论数量(如120 review)

=IMPORTXML("https://www.tripadvisor.com/Hotel_Review-g57653-d15065834-Reviews-Hampton_Inn_Suites_Culpeper-Culpeper_Virginia.html","//span[@data-test-target='reviews-count']","en_US")

注意事项

  • TripAdvisor存在反爬机制,短时间内频繁请求可能被限制访问。
  • 若后续页面结构更新,可通过浏览器开发者工具(F12)重新定位元素的特征属性,调整XPath。

内容的提问来源于stack exchange,提问作者C L

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.19 05:59:53