我尝试使用download.file()下载excel文件。R 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")
任何想法如何下载此文件?
非常感谢您的帮助!
在'url'对象有'扩展= .xlsx'和'destfile'是'.xls'。可能需要检查的东西。 – tictocchoc
@tictochoc谢谢您的回复,是的,这是一个错误,'destfile'应该是'test.xlsx'。但是,它仍然无法正常下载该文件。 – Yufrend
你现在得到什么错误? – LuckySeedling