| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- import fs from 'fs';
- import https from 'https';
- var sendCount=0;//发送次数
- async function start() {
- const data = fs.readFileSync("stock.txt", "utf-8");
- //console.log("🚀 ~ start ~ data:", data);
- if (data){
- let arr=data.split("\n");
- let arrResult=[];
- for(let i=0;i<arr.length;i++){
- if (arr[i].indexOf("CJ_ADVISE_SEL")>0){
- let str=arr[i].substring(0,6);
- arrResult.push(str);
- }
- }
- for(let i=0;i<arrResult.length;i++){
- const url = 'https://www.kylx365.com/api/SendWXServiceTemplateMessage?UserID=1&TemplateID=ErrorRemind&ParamStr=' + arrResult[i];
- console.log("🚀 ~ start ~ url:", url);
- // 使用 https.get 发起 GET 请求
- const result = await new Promise((resolve, reject) => {
- https.get(url, (res) => {
- let responseData = '';
- res.on('data', (chunk) => {
- responseData += chunk;
- });
- res.on('end', () => {
- resolve(responseData);
- });
- sendCount++;
- }).on('error', (err) => {
- reject(err);
- });
- });
- console.log("🚀 ~ start ~ result:", result);
- }
- }
- }
- start();
- var interval1=setInterval(function(){
- start();
- if (sendCount>6){
- clearInterval(interval1);
- }
- },10000);
|