我正在努力編寫一個腳本,它會以某種方式爲最新的RStudio版本的數量刮掉https://www.rstudio.com/products/rstudio/download/
,下載並安裝它。如何獲取最新的RStudio版本
由於我是R程序員,我開始使用rvest
包編寫R腳本。我設法刮掉RStudio服務器的下載鏈接,但我仍然無法獲得RStudio本身。
這裏是獲取用於Ubuntu的64位RStudio服務器的下載鏈接的R代碼。
if(!require('stringr')) install.packages('stringr', Ncpus=8, repos='http://cran.us.r-project.org')
if(!require('rvest')) install.packages('rvest', Ncpus=8, repos='http://cran.us.r-project.org')
xpath<-'//code[(((count(preceding-sibling::*) + 1) = 3) and parent::*)]'
url<-'https://www.rstudio.com/products/rstudio/download-server/'
thepage<-xml2::read_html(url)
the_links_html <- rvest::html_nodes(thepage,xpath=xpath)
the_links <- rvest::html_text(the_links_html)
the_link <- the_links[stringr::str_detect(the_links, '-amd64\\\\.deb')]
the_r_uri<-stringr::str_match(the_link, 'https://.*$')
cat(the_r_uri)
不幸的是,RStudio桌面下載頁面有完全不同的佈局,我同樣的方法不在這裏工作了。
有人可以幫助我嗎?我不敢相信,世界上所有的數據科學家都會手動升級他們的RStudio!
有一個更簡單的腳本版本,讀取RStudio-server的版本。 Bash的版本:
RSTUDIO_LATEST=$(wget --no-check-certificate -qO- https://s3.amazonaws.com/rstudio-server/current.ver)
或R版本:
scan('https://s3.amazonaws.com/rstudio-server/current.ver', what = character(0))
但RStudio桌面的版本仍然逃避我。
R Studio是否在運行時不檢查自己的更新? – Spacedman
是的,它是一個可配置的選項 - 但這不是在這裏要求的。 – mdsumner
@mdsumner是的,但RStudio是開源的,所以解決方案就在那裏。 – Spacedman