kspider
v0.1.7
Published
Simple web page spider
Downloads
8
Readme
kspider
Usages
var kspider = require("kspider");
kspider.get("https://github.com/AKIo0O/kspider", function($){
var title = $("html head title").html();// jquery selector
console.log(title); // AKIo0O/kspider
});
// co
co(function*(){
var $ = yield kspider.coget("https://github.com/AKIo0O/kspider");
console.log($("html head title").html());// AKIo0O/kspider
});
use with rules
var kspider = require("kspider");
var rules = {
title: {
get: function($){
var tags = [];
$(".l .mainer>.item a.title").each((i,el) => tags.push($(el).html()));
return tags;
}
},
adImage: {
selector: ".ad.ad-right img",
attr: "src",
base64: true
},
links: {
selector: ".l .mainer>.item a.title",
attr: "href",
},
tabTitle: {
selector: ".tab.fixed.active",
text: "html"
}
}
kspider.processWithRules("http://www.acfun.tv/v/list73/index.htm", rules , function(err, array){
console.log(err, array)// null, {title: [...titles], adImage: "base64 Image Data", links: "...hrefs", tabTitle:""}
});