【问题标题】:Google Spreadsheet returns ”xml content cannot be parsed”Google 电子表格返回“无法解析 xml 内容”
【发布时间】:2016-12-04 22:24:52
【问题描述】:

我尝试使用 importxml 将数据导入谷歌电子表格,但每次尝试都会收到相同的错误:“无法解析导入的 xml 内容”。 (原文是德语,我翻译了。)

我要导入的数据位于亚马逊产品页面的 h1 中。作为示例,我使用以下内容:https://www.amazon.de/Harry-Potter-verwunschene-Special-Rehearsal/dp/3551559007/.

你明白为什么以下方法不起作用吗?

=importXml("https://www.amazon.de/Harry-Potter-verwunschene-Special-Rehearsal/dp/3551559007/"; "//h1/span[1]")

感谢每一位帮助!

【问题讨论】:

  • Stackoverflow 用于编程问题。 Google 电子表格问题更适合WebApps

标签: xml google-sheets


【解决方案1】:

所以它现在正在由 javascript 加载,因此如果您将 URL 末尾的最后一个数字 3551559007 并将其附加到此 URL 字符串 https://www.amazon.de/gp/search-inside/service-data?method=getBookData&asin= 您将看到数据所在的原始 JSON - 您可以从那里解析它:

https://www.amazon.de/gp/search-inside/service-data?method=getBookData&asin=3551559007

所以在这种情况下,您基本上可以使用这个公式来得到标题:

=REGEXREPLACE(CONCATENATE(IMPORTDATA(A1)),"(^.*title:"")(.*)(""type:""html.*)","$2")

或者您可以找到导入 json 自定义函数并设置所有这些 - 上面会更快。

【讨论】:

    猜你喜欢
    • 2014-08-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-10
    • 2023-03-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多