Skip to content

Instantly share code, notes, and snippets.

@benwong
Created May 14, 2013 01:50
Show Gist options
  • Save benwong/5573045 to your computer and use it in GitHub Desktop.
Save benwong/5573045 to your computer and use it in GitHub Desktop.
HTML/Javascript code to extract image URLs from web page.
<div id="output">
</div>
<script type="text/javascript">
var images = document.getElementsByTagName('img'),
i,
imageUrls = [],
imageUrlString = '';
for (i = 0; i < images.length; i++) {
if (imageUrls.indexOf(images[i].getAttribute('src')) == -1) {
imageUrls[i] = images[i].getAttribute('src');
imageUrlString += images[i].getAttribute('src') + '<br/>';
}
}
document.getElementById('output').innerHTML = imageUrlString;
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment