update
This commit is contained in:
@@ -17,13 +17,19 @@ 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: 获取
|
||||
eg: 获取所有class="button" 的a标签
|
||||
|
||||
let btn=$()
|
||||
Reference in New Issue
Block a user