Skip to content

Instantly share code, notes, and snippets.

@amirrajan
Created September 12, 2015 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amirrajan/ab7b844e1f558e4ba1e9 to your computer and use it in GitHub Desktop.
Save amirrajan/ab7b844e1f558e4ba1e9 to your computer and use it in GitHub Desktop.
Get an animated gif randomly given a search term
var argv = require('yargs').argv;
console.log(argv);
var rest = require('unirest').get("https://ajax.googleapis.com/ajax/services/search/images?q=" + argv.q + "&v=1.0&safe=active&rsz=8&imgtype=animated");
var _ = require('underscore');
rest.end(function(data) {
var images = _.sortBy(
JSON.parse(data.body).responseData.results,
function() { return Math.random() })[0];
require("copy-paste").copy(images.unescapedUrl);
console.log('link copied to clipboard: ', images.unescapedUrl)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment