0

I'm trying to parse an Amazon book product page. When assigning the img src URL to a variable, like from http://www.amazon.com/dp/0553524267

var image = $('#imgBlkFront').attr('src').split(/_(.+)?/)[0] + "jpg";

or

var image = document.getElementById("imgBlkFront").src.split(/_(.+)?/)[0] + "jpg";

The variable ends up being the image data: "data:image/jpeg:base64…". What I'd like to get is the http:// URL.

empedocle
  • 1,862
  • 1
  • 14
  • 25

1 Answers1

2

This is because setting the src of an img element to base64 encoded data is a valid route of setting the source.

What is happening is jQuery is functioning correctly by returning the src attribute, but it so happens that the attribute value is a base64 encoded string instead of a traditional url

Community
  • 1
  • 1
AmmarCSE
  • 30,079
  • 5
  • 45
  • 53