Find random images from http://i.imgur.com/
HTML (152)
<img src=x
onload=console.log(s);g()
onerror=g=function(){s='http://i.imgur.com/'+Math.random().toString(36).substr(2,6)+'.png';event.target.src=s};g()>
This logs all found images on the JavaScript console using console.log()
. Works in all tested browsers (Firefox, Chrome, IE9, Safari and Opera).
The fun part is that all sorts of funny images are flashing up for the blink of an eye :).
Try it! (jsFiddle wraps this into a more complete HTML page, but browsers also accept the single element.)
Props to the amazing random string method by doubletap!
Where can I see the JavaScript console and the logged images?
- Firefox: Press Control-Shift-K (Command-Option-K on the Mac). Unselect the Net, CSS and JS buttons there, only select the Logging button.
- Opera: Press Control+Shift+i, select the Console tab.
- Chrome: Press Control+Shift+i, select the Console tab. On the bottom, select Logs.
- Safari: Basically like Chrome, but make sure first that Safari's developer tools are activated. Then press Control+Alt+C (on Windows, not sure on the Mac) instead of Control+Shift+i, select the Console tab. On the bottom, select Logs.
- IE: Press F12, select the console tab.
Perl (93 + 4 = 97)
Using imgur's own random mechanism to get their image URLs, which aren't png URLs most of the time:
$ perl -Mojo -E 'say+g("http://imgur.com/gallery/random")->dom->at("[rel=image_src]")->attrs("href")for+1..50'
http://i.imgur.com/7cNoA.jpg
...
(You need Mojolicious for this.)
PHP 5.4, 76 characters
URLs are generated in sequential order using only uppercase letters and never repeat, meeting the letter of the specification.
<?for($t=@ZZZZ;$t++;)file($u="http://i.imgur.com/$t.png")[0]>@F&&print"$u
";