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

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

因此,具体操作如下几步

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

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

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

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

> install.packages("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 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/3.5/sys_3.3.zip'
Content type 'application/zip' length 59526 bytes (58 KB)
downloaded 58 KB

trying URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/3.5/askpass_1.1.zip'
Content type 'application/zip' length 64381 bytes (62 KB)
downloaded 62 KB

trying URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/3.5/jsonlite_1.6.zip'
Content type 'application/zip' length 1160669 bytes (1.1 MB)
downloaded 1.1 MB

trying URL 'https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/windows/contrib/3.5/mime_0.8.zip'
Content type 'application/zip' length 48015 bytes (46 KB)

相关文章: