-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsmzdm.js
48 lines (45 loc) · 1.43 KB
/
smzdm.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
37
38
39
40
41
42
43
44
45
46
47
/**
* nodejs
*/
const notify = require('./sendNotify') ;
const xpath = require('xpath')
const dom = require('xmldom').DOMParser
const request = require('request');
const fs = require("fs");
let url = 'https://zhiyou.smzdm.com/member/9687682701/baoliao/';
let headers = {
'User-Agent': `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36`,
};
let opts = {
url: url,
method: 'GET',
headers: headers,
};
request(opts, (e, r, b) => {
let doc = new dom({
locator: {},
errorHandler: { warning: function (w) { },
error: function (e) { },
fatalError: function (e) { console.error(e) } }
}).parseFromString(b)
let nodes = xpath.select("//div[@class='pandect-content-stuff']", doc)
content = ''
const result=fs.readFileSync('./smzdm.txt','utf8');
nodes.forEach(function (info, index) {
let url = xpath.select("string(./div[1]/a/@href)", info);
let title = xpath.select("string(./div[1]/a)", info);
let time = xpath.select("string(./div[@class='pandect-content-type']/span)", info);
//console.log(fd.toString())
if(result.indexOf(url) == -1){
content = content + title.trim() + "\n" + url +"\n\n"
fs.appendFile('./smzdm.txt', url, err => {
if (err) {
console.error(err)
return
}
})
}
});
notify.sendNotify('smzdm', content);
console.log(content)
});