Is there any JavaScript web crawler framework?
There's a new framework that was just release for Node.js called spider. It uses jQuery under the hood to crawl/index a website's HTML pages. The API and configuration are really nice especially if you already know jQuery.
From the test suite, here's an example of crawling the New York Times website:
var spider = require('../main');
spider()
.route('www.nytimes.com', '/pages/dining/index.html', function (window, $) {
$('a').spider();
})
.route('travel.nytimes.com', '*', function (window, $) {
$('a').spider();
if (this.fromCache) return;
var article = { title: $('nyt_headline').text(), articleBody: '', photos: [] }
article.body = ''
$('div.articleBody').each(function () {
article.body += this.outerHTML;
})
$('div#abColumn img').each(function () {
var p = $(this).attr('src');
if (p.indexOf('ADS') === -1) {
article.photos.push(p);
}
})
console.log(article);
})
.route('dinersjournal.blogs.nytimes.com', '*', function (window, $) {
var article = {title: $('h1.entry-title').text()}
console.log($('div.entry-content').html())
})
.get('http://www.nytimes.com/pages/dining/index.html')
.log('info')
;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With