Pregunta

I want to fetch the images[] array of an external URL. I was able to retrieve the actual source code of the page using $.ajax, but I don't know how to access the images. Thanks.

¿Fue útil?

Solución

You could do something like

var images = [];
$(pagecode).find('img').each(function(){
   images.push( this.src );
});

Otros consejos

You can create a img tag, set src to the actual url of image, then append to a specific place:

$('<img/>').attr('src', 'http://www.google.com/intl/en_com/images/srpr/logo3w.png').appendTo('body')

You can use .load() method. The .load() method, unlike $.get(), allows you to specify a portion of the remote document to be inserted.

$('#result').load('http://www.mypage.com/myimages.htm img');

That will load every image on the page.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top