I am pulling information from a Page note from the Facebook API. In the output I get an image URL embeded in HTML code. How can I extract the image url from the HTML code below using Javascript?
<img class=\"photo_img img\" src=\"http://photos-c.ak.fbcdn.net/hphotos-ak-ash4/373909_207177302696060_189175211162936_438410_6588114253_a.jpg\" alt=\"\" />
UPDATE
The above image tag is embedded in the JSON-response from the Facebook API.
I am also using Appcelerator to create an iOS app.
UPDATE 2
I solved it with:
json.data[i].message.match(/src=(.+?[\.jpg|\.gif|\.png]")/)[1]
Thankful for all help!
Best Answer
You can use jQuery to extract any data from html. Use the following code
This will return you the src value only for the first instance of the img tag. If you want a specific img tag, you can include it inside a div.