octocat-images
v0.2.0
Published
Get octocat images name, url and even download images
Downloads
31
Readme
octocat-images
:octocat: Get or save octocat image from octodex.gituhb.com
Install
With npm do:
npm install octocat-images
Example Usage
'use strict';
let OctoCatCrawler = require('octocat-images');
let crawler = new OctoCatCrawler();
// List all octocat images
crawler.list((err, octocats) => {
if (err) throw err;
for (let octocat of octocats) {
console.log(octocat.number, octocat.name, octocat.url);
octocat.save('images');
}
});
// Give you a random choice of octocat image
crawler.choice((err, octocat) => {
console.log(octocat.number, octocat.name, octocat.url);
octocat.save('images');
});
APIs
crawler.list(cb)
Return an array include all octocat instances.
cb(err, octocats)
fires with the error or the octocats
instances will be returned.
crawler.choice(cb)
Return a random choice of octocat instance.
cb(err, octocats)
fires with the error or the octocats
instance will be returned.
octocat.save(dir)
Save the images. The images directory dir
is required.
license
MIT