Created
May 14, 2013 01:50
-
-
Save benwong/5573045 to your computer and use it in GitHub Desktop.
HTML/Javascript code to extract image URLs from web page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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