【问题标题】:Xpath importxml google spreadheetXpath importxml 谷歌电子表格
【发布时间】:2018-07-21 20:58:35
【问题描述】:

我正在尝试通过 Google 电子表格 中的 importXML 进行网页抓取,阅读此页面中的内容:

http://ddp.usach.cl/procesos-de-seleccion-internos

我需要做的是选择“Lista de Procesos”下面的列表,并将其按行分隔。我去了页面,检查并复制了 XPath

//*[@id="node-page-442"]/div[1]/div/div/div/p[5]

导致这段代码:

=importxml("http://ddp.usach.cl/node/442";"//*[@id='node-page-442']/div[1]/div/div/div/p[7]/text()")

但是,当我尝试加载它时,我收到错误 #N/A

“导入的内容为空”

【问题讨论】:

  • 我只想要这个: Lista de Procesos: SECRETARIO(A) A (DECANATO) Cargo: Administrativo, Grado 13. Lugar: Facultad Tecnológica Proceso de selección: Interno Fecha de postulación: Del 17 de Julio del 2018 年 7 月 20 日至 2018 年。Ver más。 ... 一切按行

标签: xpath google-sheets


【解决方案1】:

获取h4 元素后面的节点,内容为“Lista de Procesos”的路径是

//article[@id='node-page-442']/div[contains(@class, 'content')]/div[contains(@class, 'field-name-body')]/div[@class='field-items']/div[contains(@class,'field-item')]/h4[contains(text(), 'Lista de Procesos')]/following-sibling::*

检索到的孩子不是结构化的,而是完整的。如果您可以使用 XSLT-2.0,您可以使用 for-each-groupgroup-starting-with='strong' 来构建它们。但这只是一种可能。


表达式可以简化为简单的术语:

//h4[contains(text(),'Lista de Procesos')]/following-sibling::*

也许这更适合您的需求。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多