GoogleDoc ImportHtml(导入维基百科列表)

时间:2014-08-21 08:49:48

标签: google-docs

我正在尝试使用以下命令导入以下维基百科列表,但它不起作用,我不确定正确的索引应该是什么。

如果可能的话,我希望在一列中使用该名称,并将维基百科URL列在另一列中。

    =ImportHtml("http://en.wikipedia.org/wiki/List_of_Ice_Bucket_Challenge_participants","list", 2)

如果可能,请删除带有每个名称旁边的数字的方括号

谢谢

1 个答案:

答案 0 :(得分:0)

对于您想要做的事情,

ImportHtml不够强大/先进。 请改用IMPORTXML功能。您需要了解xpath才能编写所需的查询。

另请注意,Google文档仅支持可用的xpath函数的子集。这类似于Xpath 1.0,但仍然有些功能不起作用。不要问我为什么......

我已经去了,写下了你需要的东西。由于我不打算进入的原因,为了能够给你参考号,我必须创建一个单独的名单列表,包括和不带引用。

enter image description here

公式为:

  • A4:

    =importxml(A1,"//div[@class='div-col columns column-width']//li/a[following-sibling::sup]")
    
  • B4:

    =importxml(A1,"//div[@class='div-col columns column-width']//li/a[following-sibling::sup/a/text()]/@href")
    
  • C4:

    =importxml(A1,"//div[@class='div-col columns column-width']//li/a[following-sibling::sup/a/text()]/@href")
    
  • E4:

    =importxml(A1,"//div[@class='div-col columns column-width']//li/a[not(following-sibling::sup)]")
    
  • F4:

    =importxml(A1,"//div[@class='div-col columns column-width']//li/a[not(following-sibling::sup)]/@href")
    

修改

如果您对参考文献不感兴趣,那么您可以将所有名称放在一个列表中。

我还为图片链接添加了一个额外的查询

新公式:

  • A4:

    =importxml(A1,"//div[@class='div-col columns column-width']//li/a")
    
  • B4:

    =importxml(A1,"//div[@class='div-col columns column-width']//li/a/@href")
    
  • C4:

    ="http://en.wikipedia.org"&importxml("http://en.wikipedia.org"&B4,"//table[@class='infobox biography vcard' or @class='infobox vcard']//td[@colspan='2']//a[@class='image']/@href")