Это работает для меня:
getIt = function(what,when){
url=paste0("http://oilandgas.ky.gov/Production%20Reports%20Library/",
when,"%20-%20",what,
"%20Production.xls")
destfile=paste0("/tmp/",what,when,".xls")
download.file(url,destfile)
}
, например:
> getIt("gas",2006)
trying URL 'http://oilandgas.ky.gov/Production%20Reports%20Library/2006%20-%20gas%20Production.xls'
Content type 'application/vnd.ms-excel' length 3490304 bytes (3.3 Mb)
opened URL
==================================================
downloaded 3.3 Mb
КРОМЕ первого:
> getIt("oil",2010)
trying URL 'http://oilandgas.ky.gov/Production%20Reports%20Library/2010%20-%20oil%20Production.xls'
Error in download.file(url, destfile) :
cannot open URL 'http://oilandgas.ky.gov/Production%20Reports%20Library/2010%20-%20oil%20Production.xls'
In addition: Warning message:
In download.file(url, destfile) :
cannot open: HTTP status was '404 NOT FOUND'
хотя я могу получить газ данные 2010 в:
> getIt("gas",2010)
trying URL 'http://oilandgas.ky.gov/Production%20Reports%20Library/2010%20-%20gas%20Production.xls'
Content type 'application/vnd.ms-excel' length 4177408 bytes (4.0 Mb)
opened URL
==================================================
downloaded 4.0 Mb
Таким образом, похоже, что они изменили систему для одной ссылки. Вы можете получить эти данные, перейдя по ссылке, а затем ищите ссылку для загрузки в черновом Sharepoint HTML.
И вот почему мы ненавидим Sharepoint, детишек.
С Python, общий подход заключается в использовании [BeautifulSoup] (http://www.crummy.com/software/BeautifulSoup/) –
Почему не работает файл download.file? Работает на меня. – Spacedman
@Spacedman вы можете показать мне это, пожалуйста? Может, я что-то пропустил? – agstudy