英文:
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]"))
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论