forked from sqlwwx/mm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
umei.js
36 lines (33 loc) · 1.02 KB
/
umei.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* Created by John on 2014/8/11.
*/
var request = require('request');
var cheerio = require('cheerio');
var fs = require('fs');
var url = 'http://www.umei.cc/';
//request(url).pipe((fs.createWriteStream('umei.html')));
request(url, function (error, res, body) {
if (!error && res.statusCode == 200) {
// console.log("body:", body);
var $ = cheerio.load(body);
var li = $('DIV[class=t]');
// var a = $(li).children()[1];
// console.log("li.length:", a);
var arr = [];
li.each(function (index, ele) {
var a = $(this).children()[1];
var href = $(a).attr('href');
var title = $(a).attr('title');
var src = $('img', a).attr('src');
var obj = {
src: src,
href: 'http://www.umei.cc' + href,
title: title
};
arr.push(obj);
// console.log("src:", src);
// console.log("text:", text);
});
console.log("arr:", arr);
}
})