const express = require('express'); const axios = require('axios'); const cheerio = require('cheerio'); const app = express() const port = 3000 const config = require("./config"); app.get('/', async (req, res) => { var result = await axios.get(config.url) var $ = cheerio.load(result.data); var list = []; $("#newscontent ul li").each(function (index,value) { list.push({ type: $(this).find(".s1").text(), title: $(this).find(".s2 a").text(), news: $(this).find(".s3 a").text(), author: $(this).find(".s4").text(), url: config.url+ $(this).find(".s3 a").attr("href"), }) }); res.json(list) }) app.listen(port, () => { console.log(`Example app listening at http://localhost:${port}`) })