mirror of
https://github.com/Brandon-Rozek/Rozbot.git
synced 2024-11-07 20:30:34 -05:00
19 lines
571 B
JavaScript
19 lines
571 B
JavaScript
var promise = require('promise-polyfill');
|
|
var url = require('url');
|
|
var fetch = require('../promise/fetch.js');
|
|
|
|
module.exports = function(websiteURL) {
|
|
return new promise(function(resolve, reject) {
|
|
var weburl = url.parse(websiteURL, true, true);
|
|
if (weburl.protocol === null) {
|
|
weburl = url.parse('http://' + websiteURL);
|
|
}
|
|
websiteURL = weburl.href;
|
|
fetch(websiteURL).then(function(res) {
|
|
resolve({meta: res.meta, body: res.body});
|
|
}).catch(function(error) {
|
|
console.log(error);
|
|
reject("Sorry, I wasn't able to grab the page.");
|
|
});
|
|
});
|
|
}
|