var cheerio = require('cheerio') var axios = require('axios') let baseurl = "http://ztnew.sdbairui.com" let buglist = {} function tongzhi(info,type){ let title = `${type == 1 ? '新增bug' : '指派到:' + info.zp},${info.title}`; let data = ` ### 创建人 ${info.cj} ### 指派给 ${info.zp} ### [地址](${baseurl + info.url}) ` console.log({text:title,desp:data}) // console.log(`https://sc.ftqq.com/SCU48648T7fd03646ac5b5ea64eabc66150de705a5cb02e1c89ca0.send?text=${title}&desp=${data}`) axios.post(`https://sc.ftqq.com/SCU48648T7fd03646ac5b5ea64eabc66150de705a5cb02e1c89ca0.send`,`text=${title}&desp=${data}`).then((res)=>{ console.log(res.data) },(err)=>{ console.log(err) }) } function jiexi(html){ let $ = cheerio.load(html) let newlist = {} $("#bugList tbody tr").each((index,el)=>{ let id = $(el).find(".c-id a").text(); let title = $(el).find(".c-title").text(); let cj = $(el).find(".c-openedBy").text(); let zp = $(el).find(".c-assignedTo").text(); let url = $(el).find(".c-title a").attr('href'); let info = {id,title,cj,zp,url} if(buglist[id] == undefined){ newlist[id] = info tongzhi(newlist[id],1); }else if(zp != buglist[id].zp){ newlist[id] = info; tongzhi(newlist[id],2); }else{ newlist[id] = info; } }) buglist = newlist; } function getHtml(){ axios.get("http://ztnew.sdbairui.com/bug-browse-3-0-unresolved-0-id_asc-2-2000.html",{headers:{Cookie: 'lang=zh-cn; device=desktop; theme=default; keepLogin=on; za=xuebaoxin; preBranch=0; preProductID=3; lastProduct=3; windowWidth=1901; windowHeight=916; pagerBugBrowse=2000; qaBugOrder=id_asc; zentaosid=f05h8p09hoabg0m3a4vaksshhm; zp=2a74a2498be1d8c415d5b3dd761e4fdc7ab27cc8'}}).then((res)=>{ // console.log(res.data) let html = res.data; jiexi(html) }) } setInterval(()=>{ getHtml() },10 * 1000)