diff --git "a/Node\345\255\246\344\271\240demo\346\241\210\344\276\213/Express/\347\210\254\345\217\226\346\216\230\351\207\221\350\265\204\346\272\220/app.js" "b/Node\345\255\246\344\271\240demo\346\241\210\344\276\213/Express/\347\210\254\345\217\226\346\216\230\351\207\221\350\265\204\346\272\220/app.js" index 8977f39..cdde8b3 100644 --- "a/Node\345\255\246\344\271\240demo\346\241\210\344\276\213/Express/\347\210\254\345\217\226\346\216\230\351\207\221\350\265\204\346\272\220/app.js" +++ "b/Node\345\255\246\344\271\240demo\346\241\210\344\276\213/Express/\347\210\254\345\217\226\346\216\230\351\207\221\350\265\204\346\272\220/app.js" @@ -1,59 +1,36 @@ -const express = require('express') -const cheerio = require('cheerio') -const superagent = require('superagent') -const app = express() -let result = [] -app.use('/public', express.static('./public')) -app.engine('html', require('express-art-template')) +const express = require('express'); +const cheerio = require('cheerio'); +const superagent = require('superagent'); +const app = express(); +let result = []; +app.use('/public', express.static('./public')); +app.engine('html', require('express-art-template')); let params = { - operationName:"", - query:"", - variables: { - first:20, - after: "", - order: "POPULAR" - }, - extensions: { - query: { - id: "21207e9ddb1de777adeaca7a2fb38030" - } - } + category: "frontend", + limit: 30, + offset: 0, + order: "time" } function getInfo () { - superagent.post('https://web-api.juejin.im/query').send(params).set('X-Agent', 'Juejin/Web').end((err, res) => { + superagent.post('https://e.xitu.io/resources/gold') + .send(params) + .end((err, res) => { if (err) { return console.log(err) } - const array1 = JSON.parse(res.text).data.articleFeed.items.edges - const num = JSON.parse(res.text).data.articleFeed.items.pageInfo.endCursor - result = array1.filter(item => { - return item.node.likeCount > 50 - }) - params.variables.after = num.toString() - superagent.post('https://web-api.juejin.im/query').send(params).set('X-Agent', 'Juejin/Web').end((err, res) => { - if (err) { - return console.log(err) - } - const array2 = JSON.parse(res.text).data.articleFeed.items.edges - const result2 = array2.filter(item => { - return item.node.likeCount > 50 - }) - result2.forEach(item => { - result.push(item) - }) - }) + result = res.body.data; }) } -getInfo() +getInfo(); setInterval(() => { getInfo() -}, 10*1000*60) +}, 10*1000*24); app.get('/', (req, res, next) => { res.render('index.html', { result - }) + }); }) app.listen(3000, () => { console.log('running...') -}) \ No newline at end of file +}); diff --git "a/Node\345\255\246\344\271\240demo\346\241\210\344\276\213/Express/\347\210\254\345\217\226\346\216\230\351\207\221\350\265\204\346\272\220/views/index.html" "b/Node\345\255\246\344\271\240demo\346\241\210\344\276\213/Express/\347\210\254\345\217\226\346\216\230\351\207\221\350\265\204\346\272\220/views/index.html" index acbd5b3..fa158e1 100644 --- "a/Node\345\255\246\344\271\240demo\346\241\210\344\276\213/Express/\347\210\254\345\217\226\346\216\230\351\207\221\350\265\204\346\272\220/views/index.html" +++ "b/Node\345\255\246\344\271\240demo\346\241\210\344\276\213/Express/\347\210\254\345\217\226\346\216\230\351\207\221\350\265\204\346\272\220/views/index.html" @@ -8,16 +8,14 @@
--- 按发表顺序前40篇点赞大于50的会出现在这里