This commit is contained in:
asd
2019-12-07 19:16:42 +08:00
parent e25a22d179
commit 7f981e1d2d

View File

@@ -0,0 +1,35 @@
###需要用的库:
koa,koa-router
>用来搭建服务
superagent
>获取网页内容
cheerio
>通过jq的语法 解析网页内容
###具体步骤
1.安装所需要用的库:
yarn global(是否全局) add koa koa-router superagent cheerio
通过import 引入
2.获取网页内容:
```
superagent.get(''<网址>).end((err,res)=>{
//其中res.text 就是获取的网站内容的源代码
})
```
3.使用cheerio 通过jq分析数据
let $=cheerio.load(res.text)
eg: 获取所有class="button" 的a标签
let btn=$("a.button")