【发布时间】:2020-02-09 01:44:38
【问题描述】:
我尝试使用 Google Sheet 的 importxml 函数来获取值列表,但只需要前 12 个值。
请问我该怎么做呢?
我的查询:=IMPORTXML("https://muagame.vn/may-ps4.html","//h3")
【问题讨论】:
标签: xpath web-scraping google-sheets google-sheets-formula google-sheets-importxml
我尝试使用 Google Sheet 的 importxml 函数来获取值列表,但只需要前 12 个值。
请问我该怎么做呢?
我的查询:=IMPORTXML("https://muagame.vn/may-ps4.html","//h3")
【问题讨论】:
标签: xpath web-scraping google-sheets google-sheets-formula google-sheets-importxml
//h3 的xpath 从https://muagame.vn/may-ps4.html 的URL 中检索值。//h3 的xpath 时,检索到12 个项目。您想检索前 5 个项目。如果我的理解是正确的,那么这个答案呢?请认为这只是几个可能的答案之一。
在这个答案中,xpath 被修改了。请修改=IMPORTXML("https://muagame.vn/may-ps4.html","//h3")的xpath如下。
//h3
//li[position()<=5]/h3
h3 被放入标签 li 中。因此,为了检索h3 的第 5 项,我使用了li[position()<=5]。在本例中,公式为=IMPORTXML("https://muagame.vn/may-ps4.html","//li[position()<=5]/h3")。
如果我误解了您的问题并且这不是您想要的结果,我深表歉意。
【讨论】: