admin管理员组

文章数量:1403446

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?

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?

Share Improve this question edited Aug 17, 2015 at 8:25 Dal Hundal 3,32418 silver badges21 bronze badges asked Aug 17, 2015 at 8:03 chandnichandni 1691 silver badge7 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

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/tools/datauri/examples/index.php
  • https://en.wikipedia/wiki/Data_URI_scheme

本文标签: javascriptGetting base64 string on scraping image srcStack Overflow