nodejs 简单爬虫(一)
来源:互联网 发布:淘宝的淘气值怎么提升 编辑:程序博客网 时间:2024/06/05 02:33
package.json:
{ "name": "crawler", "version": "0.0.0", "private": true, "scripts": { "start": "node ./bin/www" }, "dependencies": { "express": "~4.9.0", "body-parser": "~1.8.1", "cookie-parser": "~1.3.3", "morgan": "~1.3.0", "serve-favicon": "~2.1.3", "debug": "~2.0.0", "ejs": "~0.8.5", "cheerio": "~0.18.0", "request": "~2.51.0" }}
关于cheerio
这里准备爬一下https://cnodejs.org/
要爬的东西是这样的
<a class="topic_title" href="/topic/5493e6c59b158a790e21dc5e" title="新手请教node.js不断回调会吃光内存吗?"> 新手请教node.js不断回调会吃光内存吗? </a>
routes/index.js
var express = require('express');var router = express.Router();var request = require('request');var cheerio = require('cheerio')/* GET home page. */router.get('/', function(req, res) { //res.render('index', { title: 'Express' }); request.get({ url:'https://cnodejs.org/' }, function (err, response, body) { if(err) {console.log(err);} var $ = cheerio.load(body); var items = []; console.log(body); $('a.topic_title').each(function(idx, element) { var $element = $(element); items.push({ title: $element.attr('title'), href: $element.attr('href') }); }); res.send(items); });});module.exports = router;访问一下看看爬到的东西
0 0
- nodejs 简单爬虫(一)
- nodejs 简单爬虫(二)
- nodejs 学习 - 简单爬虫
- Nodejs简单爬虫
- 简单 python 爬虫(一)
- nodejs简单应用一(监听服务)
- 简单高效的nodejs爬虫模型
- Python开发简单爬虫之爬虫介绍(一)
- Python 3 爬虫(一) 简单的爬虫
- python 网络爬虫(一) 简单demo
- python简单爬虫例子(一)
- Python开发简单爬虫(一)
- Python3 爬虫(一)-- 简单网页抓取
- 一个简单的爬虫(一)
- 简单python爬虫分析 (一)
- Python3 爬虫(一)-- 简单网页抓取
- Python简单的爬虫(一)
- (一)多线程简单爬虫
- 打印出100-999之间的数所有的“水仙花数”。。所谓水仙花数,就是指3位数,其各位数字立方和等于该数本身。
- CAS SERVER 登录部分定制开发
- spring mvc路径匹配原则
- 测试WeakReference和PhantomReference
- android 队列模仿listview同步加载图片
- nodejs 简单爬虫(一)
- TextView设置字体显示个数,超出部分省略号表示, 或者设置显示行数,超出部分按省略号显示
- python实战的博客
- Json转换利器Gson—— List to Json
- 批量删除".svn"文件夹方法
- IOS网络学习-5、GET请求和POST请求
- LINE_TO_STRING
- 线程池(上)
- python检测QQ是否在线