【问题标题】:Xpath between 2 texts for IMPORTXML formulaIMPORTXML 公式的 2 个文本之间的 Xpath
【发布时间】:2020-03-09 19:18:47
【问题描述】:

我已经制定了 xpath,它非常接近我的需要,但需要一些小的改进。

https://www.punters.com.au/form-guide/

我希望网站上的所有 URL 今天只在澳大利亚进行

这些是我现在拥有的 xpath。

  1. 这个提供了页面上的所有种族。包括今天所有参加比赛的国家。 - //*[@class='component-wrapper form-guide-index']/table1/tbody/tr//td/a/@href

  2. 这个提供了澳大利亚的所有种族。但包括今天、明天或网页上任何其他日期的比赛 - //tr[@class="upcoming-race__row"][preceding::tr[@class='upcoming-race__rowcoming-race__row--country']@987654323 @[*/.="Australia"]]/td[position()>=2]/a/@href

【问题讨论】:

  • 我必须为我糟糕的英语水平道歉。不幸的是,我无法理解您对 all URLs from the website racing Today and only in Australia 的期望结果。那么您能使用示例电子表格或其他方式解释它吗?
  • Tanakie,我需要上面显示的表格的 URL。我发布的 xpath 提供了我需要的 url,但包含标记表之外的数据。希望这是有道理的。
  • 感谢您的回复。我不得不为我糟糕的英语水平道歉。不幸的是,我无法理解您对回复的期望结果。但是我注意到已经发布了答案。它将解决您的问题。
  • 答案没有解决问题。如果有助于理解,这里是工作表的链接。 docs.google.com/spreadsheets/d/…

标签: xpath google-sheets google-sheets-importxml


【解决方案1】:

好的。所以这是相关主题: xpath to obtain texts between 2 tags in IMPORTXML formula

获取今天澳大利亚所有种族的链接(在 GoogleSheets 中将“替换为 '):

//tr[@class="upcoming-race__row"][preceding::td[@class="upcoming-race__country-title"][1][.="Australia"]][preceding::h2[1][.="Today"]]/td[position()>=2]/a/@href

替代 XPath:

//h2[.="Today"]/following::table[1]//tr[@class="upcoming-race__row"][preceding::td[@class='upcoming-race__country-title'][1][.="Australia"]]/td[position()>=2]/a/@href

//div[@class="component-wrapper form-guide-index"]/table[1]//tr[@class="upcoming-race__row"][preceding::td[@class='upcoming-race__country-title'][1][.="Australia"]]/td[position()>=2]/a/@href

【讨论】:

  • XPath 有效(刚刚更新了您的工作表)。为了以防万一,我又加了两个。不要忘记在 GoogleSheets 中将 " 替换为 '。
猜你喜欢
  • 2020-06-19
  • 1970-01-01
  • 1970-01-01
  • 2013-05-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-30
相关资源
最近更新 更多