|
|
@@ -1,32 +1,52 @@
|
|
1
|
1
|
import fs from 'fs';
|
|
2
|
2
|
import https from 'https';
|
|
3
|
3
|
|
|
|
4
|
+
|
|
|
5
|
+var sendCount=0;//发送次数
|
|
|
6
|
+
|
|
4
|
7
|
async function start() {
|
|
5
|
8
|
const data = fs.readFileSync("stock.txt", "utf-8");
|
|
6
|
|
- console.log("🚀 ~ start ~ data:", data);
|
|
|
9
|
+ //console.log("🚀 ~ start ~ data:", data);
|
|
7
|
10
|
if (data){
|
|
8
|
|
- const url = 'https://www.kylx365.com/api/SendWXServiceTemplateMessage?UserID=1&TemplateID=ErrorRemind&ParamStr=' + data;
|
|
9
|
|
-
|
|
10
|
|
- // 使用 https.get 发起 GET 请求
|
|
11
|
|
- const result = await new Promise((resolve, reject) => {
|
|
12
|
|
- https.get(url, (res) => {
|
|
13
|
|
- let responseData = '';
|
|
14
|
|
- res.on('data', (chunk) => {
|
|
15
|
|
- responseData += chunk;
|
|
16
|
|
- });
|
|
17
|
|
- res.on('end', () => {
|
|
18
|
|
- resolve(responseData);
|
|
|
11
|
+
|
|
|
12
|
+ let arr=data.split("\n");
|
|
|
13
|
+ let arrResult=[];
|
|
|
14
|
+ for(let i=0;i<arr.length;i++){
|
|
|
15
|
+ if (arr[i].indexOf("CJ_ADVISE_SEL")>0){
|
|
|
16
|
+ let str=arr[i].substring(0,6);
|
|
|
17
|
+ arrResult.push(str);
|
|
|
18
|
+ }
|
|
|
19
|
+ }
|
|
|
20
|
+
|
|
|
21
|
+ for(let i=0;i<arrResult.length;i++){
|
|
|
22
|
+ const url = 'https://www.kylx365.com/api/SendWXServiceTemplateMessage?UserID=1&TemplateID=ErrorRemind&ParamStr=' + arrResult[i];
|
|
|
23
|
+ console.log("🚀 ~ start ~ url:", url);
|
|
|
24
|
+ // 使用 https.get 发起 GET 请求
|
|
|
25
|
+ const result = await new Promise((resolve, reject) => {
|
|
|
26
|
+ https.get(url, (res) => {
|
|
|
27
|
+ let responseData = '';
|
|
|
28
|
+ res.on('data', (chunk) => {
|
|
|
29
|
+ responseData += chunk;
|
|
|
30
|
+ });
|
|
|
31
|
+ res.on('end', () => {
|
|
|
32
|
+ resolve(responseData);
|
|
|
33
|
+ });
|
|
|
34
|
+ sendCount++;
|
|
|
35
|
+ }).on('error', (err) => {
|
|
|
36
|
+ reject(err);
|
|
19
|
37
|
});
|
|
20
|
|
- }).on('error', (err) => {
|
|
21
|
|
- reject(err);
|
|
22
|
38
|
});
|
|
23
|
|
- });
|
|
24
|
39
|
|
|
25
|
|
- console.log("🚀 ~ start ~ result:", result);
|
|
|
40
|
+ console.log("🚀 ~ start ~ result:", result);
|
|
|
41
|
+ }
|
|
26
|
42
|
}
|
|
27
|
43
|
}
|
|
28
|
44
|
|
|
29
|
|
-setInterval(function(){
|
|
|
45
|
+start();
|
|
|
46
|
+var interval1=setInterval(function(){
|
|
30
|
47
|
start();
|
|
|
48
|
+ if (sendCount>6){
|
|
|
49
|
+ clearInterval(interval1);
|
|
|
50
|
+ }
|
|
31
|
51
|
},10000);
|
|
32
|
52
|
|