我尝试使用download.file()下载excel文件.
如果我使用浏览器直接转到链接,我可以毫无问题地下载文件.
但是,使用download.file只会下载包含Excel错误的损坏文件:"您尝试打开的文件格式与文件扩展名指定的格式不同."
这是我的代码:
url <- "http://obieebr.banrep.gov.co/analytics/saw.dll?Download&Format=excel2007&Extension=.xlsx&BypassCache=true&path=%2Fshared%2fSeries%20Estad%c3%adsticas%2F1.%20Tasa%20Interbancaria%20%28TIB%29%2F1.1.TIB_Serie%20hist%C3%B3rica%20IQY&lang=es&NQUser=publico&NQPassword=publico&SyncOperation=1"
download.file(url, destfile = paste0(base_dir, "test.xls"), mode = "wb", method="libcurl")
Run Code Online (Sandbox Code Playgroud)
有任何想法如何下载此文件?
非常感谢您的帮助!
小智 6
试试这个,它对我有用:
download.file(url,destfile = "./second.xlsx",mode = "wb")
Run Code Online (Sandbox Code Playgroud)