-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetresume.js
More file actions
112 lines (102 loc) · 3.1 KB
/
getresume.js
File metadata and controls
112 lines (102 loc) · 3.1 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// cache进行缓存,目前已有的候选人列表
let cache = new Set()
// 每次发消息的内容
let msg = []
let targetCandidate = []
function getHttpHeader(pageNum) {
let options = {
method: 'POST',//post请求
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({//post请求参数
channel: [],
education: ["2", "3"],
flow_status: ["0", "8"],
graduate_time: 2022,
id: "",
idcard: "",
idepts: [],
isUnRead: 0,
is_deploy: null,
is_full: 0,
is_mine: 0,
keyword: "",
last_update: "",
// 每次请求获取的候选人数量
limit: 20,
mobile: "",
name: "",
orderBy: "update_time",
// 第几页
page: pageNum,
qq: "",
rank: [],
recruit_city: [],
recruit_project: [],
school: "",
score_type: "",
speciality: "",
station: ["103", "102"],
tag_id: [],
work_city: ["3"],
})
}
return options
}
function search(options) {
return new Promise((resolve, reject) => {
fetch('http://campus.oa.com/campusCenterApi/v1/resume/search', options).then((res) => {
if(res.ok){//如果取数据成功
res.json().then((data) => {
let list = data.data.list
let total = data.data.total
for(let i =0; i<list.length; i++) {
if(!cache.has(list[i].id)){
cache.add(list[i].id)
msg.push({
id: list[i].id,
url: `http://campus.oa.com/#/resumeview?rid=${list[i].rid}`
})
}
// 满足执行条件
// if(targetCandidate.indexOf(list[i].id) > -1) {
// window.open(`http://campus.oa.com/#/resumeview?rid=${list[i].rid}`, "_blank");
// }
}
resolve(total)
})
}
})
})
}
function searchAllPages() {
search(getHttpHeader(1)).then((total) => {
for(let i = 2; i < Math.ceil(total/20)+1; ++i){
search(getHttpHeader(i))
}
})
}
function randomNum(minNum, maxNum){
return parseInt(Math.random() * ( maxNum - minNum + 1 ) + minNum, 10);
}
// 第一次执行, 更新一下cache
// searchAllPages()
// msg = []
// 间隔时间执行
function cycleSearch() {
let time = new Date()
if(time.getHours() > 0 && time.getHours() < 9) {
return
}
setTimeout(() => {
searchAllPages()
}, randomNum(1,5)*1000*60)
}
setInterval(cycleSearch, 30*60*1000)
setInterval(() => {
console.log(new Date(), '简历来啦', msg)
if (msg) alert('简历来啦:' + msg)
msg = []
}, 20*60*1000)