-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjj.js
81 lines (79 loc) · 2.2 KB
/
jj.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
const Flow = require("./workflow");
const flow = new Flow();
const getFund = (code) => {
return new Promise((resolve, reject) => {
// let url = `http://fund.eastmoney.com/${code}.html`;
let timestamp = new Date().getTime();
let url = `http://fundgz.1234567.com.cn/js/${code}.js?rt=${timestamp}`;
flow.get(url)
.then((body) => {
function jsonpgz(obj) {
let title = obj.name + "(" + obj.fundcode + ")";
let subtitle = obj.gszzl + "%";
if (obj.gszzl > 0) {
icon = flow.icon("up.png");
} else {
icon = flow.icon("down.png");
}
if (title && subtitle) {
resolve({
title,
subtitle,
icon,
arg: `http://fund.eastmoney.com/${code}.html`
});
} else {
reject();
}
}
eval(body);
// let title = "";
// let subtitle = "";
// let icon = {};
// const reg1 = /<div class="fundDetail-tit"><div style="float: left">(.+?)<span>\(<\/span><span class="ui-num">(.+?)<\/span><\/div>\)<\/div>/;
// const reg2 = /<span class="ui-font-middle.+?ui-num" id="gz_gszzl">(.+?)<\/span>/;
// let matches1 = body.match(reg1);
// if (matches1 && matches1.length > 1) {
// title = matches1[1] + "(" + matches1[2] + ")";
// }
// let matches2 = body.match(reg2);
// if (matches2 && matches2.length > 0) {
// subtitle = matches2[1];
// }
// if (subtitle.indexOf("+") > -1) {
// icon = flow.icon("up.png");
// } else {
// icon = flow.icon("down.png");
// }
// if (title && subtitle) {
// resolve({
// title,
// subtitle,
// icon,
// arg: `http://fund.eastmoney.com/${code}.html`
// });
// } else {
// reject();
// }
}).catch((err) => {
reject();
});
});
}
flow.getItem("jj")
.then((data) => {
if (data && data.length > 0) {
let arr = [];
data.forEach((code) => {
arr.push(getFund(code));
});
Promise.all(arr).then((data) => {
flow.log(data);
})
.catch((err) => {
flow.log([{
title: '暂无数据'
}]);
});
}
});