基于rvest的web抓取图像质量分析

基于rvest的web抓取图像质量分析,r,image,web-scraping,rvest,R,Image,Web Scraping,Rvest,我抓取了一张图像,如下所示: library(rvest) library(magrittr) url = 'http://x.yupoo.com/photos/05941188/albums' web = read_html(url) 现在我需要考虑节点。我将使用extract2()函数选择精确的节点: gianni = html_nodes (web, '.showindex__gallerycardwrap') ugo = gianni %>% extract2(1) %>

我抓取了一张图像,如下所示:

library(rvest)
library(magrittr)
url = 'http://x.yupoo.com/photos/05941188/albums'
web = read_html(url)
现在我需要考虑节点。我将使用
extract2()
函数选择精确的节点:

gianni = html_nodes (web, '.showindex__gallerycardwrap')
ugo = gianni %>%  extract2(1) %>%  html_nodes('img') %>%  html_attr('src')
现在我下载图片。我使用
download.file
函数来实现这一点,它要求我构建一个新的对象
协议
,以获得完整的URL字符串:

protocol = 'http:'
scarica = download.file(paste0(url,ugo[1], destfile = 'imm.jpg', method = 'wininet')
当我看到图像时,它看起来像这样,这显然不是我所期望的质量:


用“http:”创建链接,而不是用“url:”创建链接,这对我来说很有帮助:

download.file(paste0("http:",ugo[1]),destfile = "imm.jpg", method = 'wininet',mode='wb')

谢谢,真正有区别的是“模式”=wb选项,我不知道为什么,但现在它工作了!