【问题标题】:How to figure out proper xpath for importxml in google sheets?如何在谷歌表格中为 importxml 找出正确的 xpath?
【发布时间】:2019-01-13 22:08:13
【问题描述】:

我正在尝试从 http://wwwinfo.mfcr.cz/cgi-bin/ares/darv_std.cgi?ico=00064581

到带有函数 IMPORTXML 的 Google 表格,

尝试获取主题名称、ID 和地址(等),但我无法找到正确的 xpath 来获取它,接收导入的内容是空的。我可以做//*,但这并不是我所需要的。请给我一些提示好吗?

【问题讨论】:

    标签: xpath google-sheets


    【解决方案1】:

    例如,您可以使用这样的东西作为单元格的公式:

    =importxml("http://wwwinfo.mfcr.cz/cgi-bin/ares/darv_std.cgi?ico=00064581", "//*[name()='are:Shoda_ICO']")
    

    如果你想获得多个元素:

    =importxml("http://wwwinfo.mfcr.cz/cgi-bin/ares/darv_std.cgi?ico=00064581", "//*[name()='dtt:Nazev_obce' or name()='are:Shoda_ICO']")
    

    【讨论】:

    • 谢谢。我怎样才能结合更多呢?与此同时,我通过 IMPORTDATA 和经常使用函数来解决它,这导致了这个代码: =REGEXEXTRACT(QUERY(ARES!A2:A100, "select A where A start with ''"), "\>(.*)\
    • 我试过这样://*[contains(local-name(), 'ICO')]|//*[contains(local-name(), 'Nazev_obce')]方法对吗?
    • @Jakub 出于某种原因“包含”不适用于 importxml,我编辑了答案
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多