Fun with Images and Ajax

I did a decent amount of coding around images today. I worked on several different coding creations after a sprint of inspiration from a blog post earlier this week. That post described work done to find duplicate images on the imgur website, and I wanted to see if I could create something similar. I ended up creating a quick python script to grab images from imgur, see if they are real or merely a removed image, then store the links to the real ones. I found similar results to what they found, and my code is over on github right here.

After that, I wanted to find out how to do more with ajax requests and traversing the DOM, so I made a quick fiddle to get images from the website 500px. Luckily, 500px allows requests from other sites, so it is easy to get the images, but finding the location was a little bit trickier. Ultimately, I ended up figuring out where in the file the link to the image source was located and found that it was easy to just grab that link:

fullText = xmlhttp.responseText;
tagLocation = fullText.substring(fullText.indexOf('nude_placeholder'));
linkStart = tagLocation.substring(tagLocation.indexOf('src="')+5);
myResponse = linkStart.substring(0,linkStart.indexOf('"'));
heyo = document.getElementById('meI');
heyo.innerHTML = '<img src="'+myResponse+'">';

I put all of that into a jsfiddle so that it has a slideshow with images changing every five seconds. The fiddle is here, and below.

Finally, I ended up changing some code I wrote earlier to grab images based on my website maker. Instead of using server-side code, I put everything into JavaScript so that I can run the page anywhere. That code was pretty trivial to write, although I discovered that I could no longer use shutterstock, as they do not allow for non-origin requests. I tried to find a workaround, but ultimately just used 500px again. That code is up on github.