=ImportXML在Google Sheets中完成此操作的正确输入是什么?

huangapple go评论62阅读模式
英文:

What is the right input to complete this =ImportXML in Google Sheets

问题

我正在尝试自动从Trip Advisor获取评论数量和评分...我该如何找到正确的XPath查询来提取?我一直在尝试提取数据,但要么出现错误,要么只能获取到标题。

=IMPORTXML("https://www.tripadvisor.com/Hotel_Review-g57653-d15065834-Reviews-Hampton_Inn_Suites_Culpeper-Culpeper_Virginia.html","/html/body/div[2]/div[2]/div[2]/div[4]/div/div/div[4]/div/div/div/div/div[2]/div1/div1/span","en_US")

我知道上面的XPath不是正确的...如果有人知道要获取"120条评论"和"4.5/5"的最佳输入是什么,将不胜感激!

=IMPORTXML("https://www.tripadvisor.com/Hotel_Review-g57653-d15065834-Reviews-Hampton_Inn_Suites_Culpeper-Culpeper_Virginia.html","/html/body/div[2]/div[2]/div[2]/div[4]/div/div/div[4]/div/div/div/div/div[2]/div1/div1/span","en_US")

我知道上面的XPath不是正确的...如果有人知道要获取"120条评论"和"4.5/5"的最佳输入是什么,将不胜感激!

英文:

I am trying to automate pulling number of review and rating from Trip Advisor... how would I find the right xpath query to pull? I have been trying to pull and have been getting errors or just the headers.

=IMPORTXML("https://www.tripadvisor.com/Hotel_Review-g57653-d15065834-Reviews-Hampton_Inn_Suites_Culpeper-Culpeper_Virginia.html","/html/body/div[2]/div[2]/div[2]/div[4]/div/div/div[4]/div/div/div/div/div[2]/div1/div1/span","en_US")

I know the xpath is not the one represented above... if anyone knows what the best input would be to get "120 review" and "4.5/5", it'd be greatly appreciated!

=IMPORTXML("https://www.tripadvisor.com/Hotel_Review-g57653-d15065834-Reviews-Hampton_Inn_Suites_Culpeper-Culpeper_Virginia.html","/html/body/div[2]/div[2]/div[2]/div[4]/div/div/div[4]/div/div/div/div/div[2]/div1/div1/span","en_US")

I know the xpath is not the one represented above... if anyone knows what the best input would be to get "120 review" and "4.5/5", it'd be greatly appreciated!

答案1

得分: 0

Rating: =importxml(A1, "//*[@id='ABOUT_TAB']/div[2]/div[1]/div[1]/span[1]")&"/5"

Reviews: =join(,importxml(A1, "//*[@id='ABOUT_TAB']/div[2]/div[1]/div[1]/a[1]/span[2]"))

英文:

You may try:

Rating: =importxml(A1,"//*[@id='ABOUT_TAB']/div[2]/div[1]/div[1]/span[1]")&"/5"

Reviews: =join(,importxml(A1,"//*[@id='ABOUT_TAB']/div[2]/div[1]/div[1]/a[1]/span[2]"))

=ImportXML在Google Sheets中完成此操作的正确输入是什么?

huangapple
  • 本文由 发表于 2023年6月9日 03:22:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76435092.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定