diff --git a/2019/用node写爬虫.md b/2019/用node写爬虫.md index 37f34d5..de78d29 100644 --- a/2019/用node写爬虫.md +++ b/2019/用node写爬虫.md @@ -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: 获取 \ No newline at end of file +eg: 获取所有class="button" 的a标签 + +let btn=$() \ No newline at end of file