在抓取图像src上获取base64字符串 [英] Getting base64 string on scraping image src

查看:81
本文介绍了在抓取图像src上获取base64字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从网站抓取图像src,标题,价格等,但它提供了base64字符串代替图像src.当我将所有这些已抓取的数据附加到uri时,它会显示uri较长的错误.如何减慢这个问题?

I am scraping image src, title, price etc from website but it gives base64 string in place of image src. When i'm appending all these scraped data to uri, it shows error long uri. How to slow this problem?

推荐答案

如果您将base64字符串用作img src,则听起来好像图像是内联编码的.

If you're getting a base64 string as the img src, it sounds as though the image is encoded inline.

数据:URI是一种非常有用的方法,可将少量数据嵌入到URL-URL包含链接的URL,而不是链接到外部资源的URL实际的编码数据.

data: URIs are a very useful way to embed small items of data into a URL—rather than link to an external resource, the URL contains the actual encoded data.

 

嵌入小红点图片的HTML片段:

An HTML fragment embedding a picture of small red dot:

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA
AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
9TXL0Y4OHwAAAABJRU5ErkJggg==" alt="Red dot" />

在上面的示例中,如果要对字符串进行base64解码(减去 data:image/png,base64,部分),您将获得可以编写的PNG图片的数据磁盘作为文件.

In the example above, if you were to base64 decode the string (minus the data:image/png,base64, part), you would get the data of a PNG image which you could write to disk as a file.

这篇关于在抓取图像src上获取base64字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆