问题
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