如何使用Google表格中的ImportXML从meta属性中过滤日期

问题描述

我正在设置一个Google表格来从我网站上某些文章中抓取发布日期。 Here's an example post(如果有帮助)。

我为每个帖子生成了元标签,如下所示:

<Meta property="article:published_time" content="2018-12-14T19:41+00:00" />

因此,我使用以下代码来刮写发布日期,其中A列是链接位置:

=IMPORTXML(A2,"//Meta[@property='article:published_time']/@content")

但是,这会刮除完整的元内容,其中包括时间: 2018-12-14T19:41 + 00:00

我只想要 2018-12-14 ,同时从T字开始剥离所有内容。有没有办法用xpath过滤掉它?

解决方法

尝试:

=REGEXEXTRACT(IMPORTXML(A2,"//meta[@property='article:published_time']/@content"),"(.+)T")

enter image description here