首页 > 解决方案 > 有什么想法为什么我不能用 R 下载这个 xlsx?

问题描述

这是页面: https://ceegex.hu/en/market-data/daily-data?market_data_day_filter%5BstartDate%5D=2018-03-08&market_data_day_filter%5BendDate%5D=2018-03-30

我们在哪里得到“下载为 xlsx”按钮。这个按钮的地址是: https://ceegex.hu/en/market_data/day/export.xlsx?startDate=2018-03-08&endDate=2018-03-30&_format=xlsx

此地址下载 xlsx 文件。我想对 R 做同样的事情,所以我写了: download.file("https://ceegex.hu/en/market_data/day/export.xlsx?startDate=2018-03-08&endDate=2018-03-30&_format=xlsx", "myfile.xlsx")
但我得到了像Error in download.file,之类的错误cannot open URL

标签: r

解决方案


问题是该文件在网站中不存在,这是在您按下按钮时创建的。尝试使用 curl 方法:

download.file("https://ceegex.hu/en/market_data/day/export.xlsx?startDate=2018-03-08&endDate=2018-03-30&_format=xlsx", 
              "myfile.xlsx", method = "curl")

推荐阅读