1.0.2 • Published 7 years ago
urlfetcher v1.0.2
urlfetcher
A simplistic library to fetch remote content on the internet, which supports both HTTP & HTTPS, with beautiful, understandable syntax.
Usage
var urlFetcher = require('urlfetcher');
urlFetcher.fetch('https://pastebin.com/').then(function(result) {
console.log(result);
// it worked
}, function(error) {
// oh no an error!
console.log(error);
});
Search Function
Upon getting a response, like in the above example, you can then search for a string, for example if we use the request above, and look for "pastebin" we'll be able to find a match, like so:
var urlFetcher = require('urlfetcher');
urlFetcher.fetch('https://pastebin.com/').then(function(result) {
console.log(result);
if(urlFetcher.search(result, 'Please refresh the page to continue'))
console.log('Found string');
else
console.log('Failed to locate string');
}, function(error) {
console.log(error);
});
Bugs
Please submit a pull request on github if you found a bug, thanks!