}).on('end',function(err){
if(err){
console.log(err);
}
if(page==10){
res.render('index',{
lists:list
});
}
});
},
function(err){
console.log(err);
}
);
});
//监听
app.listen(8080);
view/index.html页面
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<style>
table{
width:1300px;
border:1px solid #ccc;
border-collapse: collapse;
text-align: center;
margin:0 auto;
}
td,tr,th{
border:1px solid #ccc;
border-collapse: collapse;
}
tr{
height:30px;
line-height: 30px;
}
</style>
<body>
<table>
<thead>
<tr>
<th>公司名称</th>
<th>公司地址</th>
<th>薪资</th>
<th>公司描述</th>
<th>岗位名称</th>
</tr>
</thead>
<tbody>
{% for list in lists %}
<tr>
<td>{{list.company}}</td>
<td>{{list.area}}</td>
<td>{{list.salary}}</td>
<td>{{list.description}}</td>
<td>{{list.job_title}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</body>
</html>5.启动
直接通过 node app.js启动即可;
6.运行结果(http://localhost:8080),只截取部分数据

总结
以上所述是小编给大家介绍的NodeJs实现简单的爬虫功能,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对软件开发网网站的支持!









