Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting base64 string on scraping image src

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?

like image 651
chandni Avatar asked Aug 17 '15 08:08

chandni


1 Answers

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
like image 78
Dal Hundal Avatar answered Oct 26 '22 14:10

Dal Hundal