【问题标题】:How import via IMPORTXML text value of "/a" only if "/a/@href" exists?仅当“/a/@href”存在时,如何通过“/a”的 IMPORTXML 文本值导入?
【发布时间】:2020-08-13 22:06:59
【问题描述】:

当前公式:
IMPORTXML("https://int.soccerway.com/international/europe/uefa-champions-league/20192020/s17689/final-stages/","//td[@class='team team-a'] | //td[@class='team team-a strong']/a")

//td[@class='team team-a']//td[@class='team team-a strong']/a 的导入值如何仅存在 //td[@class='team team-a']/@href//td[@class='team team-a strong']/a/@href 值?

示例:

Winner Semi-final 2Winner Semi-final 1 不包含链接 /@href

RB Leipzig 包含链接/@href - https://int.soccerway.com/teams/germany/rb-leipzig/13410/
PSG 包含链接/@href - https://int.soccerway.com/teams/france/paris-saint-germain-fc/886/

我想要的导入结果是这样的:

RB莱比锡
巴黎圣日耳曼

【问题讨论】:

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


    【解决方案1】:

    如果我理解正确,这应该会有所帮助:

    =IMPORTXML(url,"//h2[span='Semi-finals']/following-sibling::div[@class='content']//td[contains(@class,'team')]/a[@href]")
    

    输出:

    RB Leipzig
    PSG
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-21
      • 2014-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-01
      相关资源
      最近更新 更多