2018-12-05爬虫

koa2 爬虫
cheerio

const Koa = require('koa');
const app = new Koa();
const router=require('koa-simple-router');
const request = require('request');
const cheerio = require('cheerio');

app.use(router(_ => {
    _.get("/",  (ctx,next)=>{
        ctx.set('Content-Type', 'text/html');
        ctx.body =  request('http://www.jikexueyuan.com',  (error, response, body)=> {
            if (!error && response.statusCode == 200) {
                
                $= cheerio.load(body);
                $.html(".aside-cList");
            }
        });

    })
}))


app.listen(3000,()=>{
    console.log("'Example app listening on port 3000!'");
});



你可能感兴趣的:(2018-12-05爬虫)