r - 如何获取最新的 RStudio 版本

标签 r bash xpath rstudio

我正在努力编写一个脚本,该脚本会以某种方式从 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/

相关文章:

macos - 如何在 OS X 中获取 Bash 版本号

r - 如何在多个多面 ggplot2 图形中实现相同的面大小和比例?

基于 2 列删除重复值

linux - 如何在 Bash 中提取引号之间的字符串

javascript - 无法弄清楚为什么我无法使用 Xpath 检索简单的字符串

Python 和 libxml2 : how to iterate in xml nodes with XPATH

selenium - XPATH - 为什么在 text() 函数中使用括号

r - 使用dplyr摘要对多个列进行不同的操作

r - 将点图与 ggplot 连接起来。与 geom_line 连接

bash - Unix/bash。对于带有数字的文件名并行两个 for 循环