Rstudio安装“rvest”时出现错误,如何调整

时间:2024-10-09 06:56:24

在利用R进行爬虫,时安装“rvest”包,时出现了错误,出现的错误提示如下:

Warning in install.packages :
  package ‘rvest’ is not available (for R version 3.5.3)
Error in : error reading from connection

因此,具体操作如下几步

1.首先,需要将Rstudio默认的下载镜像切换成国内的下载镜像;

2.有多个国内下载镜像,还不行就多试几次,我选择的是北京大学的下载镜像;

3.输入:("rvest"),等待安装成功;

> ("rvest")
also installing the dependencies ‘sys’, ‘askpass’, ‘jsonlite’, ‘mime’, ‘openssl’, ‘xml2’, ‘httr’, ‘selectr’
  There is a binary version available but the source version is later:
         binary source needs_compilation
jsonlite    1.6  1.6.1              TRUE

  Binaries will be installed
trying URL '/CRAN/bin/windows/contrib/3.5/sys_3.'
Content type 'application/zip' length 59526 bytes (58 KB)
downloaded 58 KB

trying URL '/CRAN/bin/windows/contrib/3.5/askpass_1.'
Content type 'application/zip' length 64381 bytes (62 KB)
downloaded 62 KB

trying URL '/CRAN/bin/windows/contrib/3.5/jsonlite_1.'
Content type 'application/zip' length 1160669 bytes (1.1 MB)
downloaded 1.1 MB

trying URL '/CRAN/bin/windows/contrib/3.5/mime_0.'
Content type 'application/zip' length 48015 bytes (46 KB)