Getting base64 string on scraping image src

被刻印的时光 ゝ 提交于 2021-01-27 06:35:56

问题


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?


回答1:


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

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.

 

An HTML fragment embedding a picture of small red dot:

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

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.

  • http://dopiaza.org/tools/datauri/examples/index.php
  • https://en.wikipedia.org/wiki/Data_URI_scheme


来源:https://stackoverflow.com/questions/32045408/getting-base64-string-on-scraping-image-src

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!