我正在努力编写一个脚本,该脚本会以某种方式从 https://www.rstudio.com/products/rstudio/download/
中获取最新 RStudio 版本的编号,下载它并安装它。
因为我是一名 R 程序员,所以我开始使用 rvest
包编写 R 脚本。我设法抓取了 RStudio 服务器的下载链接,但我仍然无法获取 RStudio 本身。
这是获取 64 位 RStudio-server for Ubuntu 下载链接的 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 服务器的版本。 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-desktop 的版本仍然让我望而却步。
最佳答案
好像可以从url http://download1.rstudio.org/current.ver 得到最新的稳定版本号并且它是最新的(出于某种未知原因),至少在撰写此答案时是这样。
$ curl -s http://download1.rstudio.org/current.ver
1.1.447
$ curl -s https://www.rstudio.org/links/check_for_update?version=1.0.0 | grep -oEi '更新版本=([0-9]+\.[0-9]+\.[0-9]+)' | awk -F= '{print $2}'
1.1.423
在这里找到:https://github.com/yutannihilation/ansible-playbook-r/blob/master/tasks/install-rstudio-server.yml
关于r - 如何获取最新的 RStudio 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46023031/