website
Version:
A set of tools for extracting information out of a website.
34 lines (27 loc) • 648 B
JavaScript
/*
* node-website
* A set of tools for extracting information out of a website.
*
* Licensed under the MIT:
* http://www.opensource.org/licenses/mit-license.php
*
* Copyright (c) 2013, André König (andre.koenig@gmail.com)
*
*/
var request = require('request'),
cheerio = require('cheerio');
exports.getTitle = function (uri, cb) {
'use strict';
request({
uri: uri
}, function (error, response, body) {
var $,
title;
if (error) {
return cb(error);
}
$ = cheerio.load(body);
title = $('title').text().trim();
cb(null, title);
});
};