尝试使用 importxml 将 XE.com 抓取到 GoogleSheets 电子表格中

Trying to scrape XE.com into a GoogleSheets spreadsheet with importxml

我想要实现的目标应该相当简单,我可以在 excel 中使用 PowerQuery 来实现,但对于 Google Sheets 来说还是比较新的。

我正在使用 importxml 函数从 link:

中导入 table

https://www.xe.com/currencytables/?from=EUR&date=2020-10-31

=importxml("https://www.xe.com/currencytables/?from=EUR&date=2020-10-31", "//td")

然而,我得到的结果全部导入到一列中,我需要它的格式与 html table 中的格式相同,保留 headers 并具有货币代码在一栏中,货币汇率在另一栏中,然后是接下来两栏中的汇率。

我如何修改 importxml 函数来实现这一点?

改用IMPORTHTML

公式:

=IMPORTHTML("https://www.xe.com/currencytables/?from=EUR&date=2020-10-31", "table", 1)

  • 这将在提供的 URL 中获得第一个 table。

输出:

参考: