我在google doc电子表格的单元格中有以下功能:
=IMPORTXML(J15, "//meta[@name='description']/@content")
我需要从this脸谱页面的以下一行捕获值: https://www.facebook.com/pages/Christine-Simpson/135960496435727
<meta name="description" content="Christine Simpson. 68 likes · 3 talking about this. Christine Laura Simpson
is a Canadian television personality, best known as a hockey reporter,
host...">
此功能正常运行,并在我的google docs单元格中输出以下内容:
"Christine Simpson. 68 likes · 3 talking about this. Christine Laura Simpson
is a Canadian television personality, best known as a hockey reporter,
host..."
但是,我只需捕捉&#34;喜欢的数量&#34;从这个字符串和&#34;谈论这个&#34;进入我的细胞并摆脱所有其他文本。
我尝试了以下方法,以便在返回的字符串上使用XPATH的tokenize()函数。
=IMPORTXML(J2, "tokenize('//meta[@name='description']/@content', '.')")
但是,我收到一个错误:&#34;导入的XML无法解析&#34;
任何帮助都将不胜感激。
THX
答案 0 :(得分:0)
这是因为IMPORTXML
期望 Xpath 表达式(类似//meta[@name='description']/@content
)作为第二个参数。
您可以使用正则表达式来提取所需的数据
=REGEXEXTRACT(A1,"[0-9]+\s+likes")
=REGEXEXTRACT(A1,"[0-9]+\s+talking\s+about\s+this")