从数据URI获取图像 [英] Getting image from data uri
本文介绍了从数据URI获取图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试抓取数据,并且数据之一也是图像,该图像已嵌入数据uri中.我想不出要用r做到这一点很热.
I'm trying to scrap data and one of the data is also the image, which is embeded in data uri. I can't figure it out hot to do this with r.
library(rvest)
webUrl<-"https://portaltramites.inpi.gob.ar/Marcas/Logo?Acta=3363531"
imgscr<- read_html(webUrl) %>%
html_node(xpath = '//*/img') %>%
html_attr('src')
img<-gsub("data:image/gif;base64,","",imgsrc, fixed=true)
head(img)
#now I'm stuck
推荐答案
library(rvest)
library(openssl)
library(magick)
pg <- read_html("https://portaltramites.inpi.gob.ar/Marcas/Logo?Acta=3363531")
img <- html_nodes(pg, "img")
img_src <- html_attr(img, "src")
img_src <- gsub("^data.*base64,", "", img_src)
image_read(base64_decode(img_src))
然后,您可以使用其他 magick
软件包功能来保存/操作/等.
You can then use other magick
package functions to save/manipulate/etc.
这篇关于从数据URI获取图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文