-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
913fdf2
commit 6fff4d4
Showing
2 changed files
with
22 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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...') | ||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters