1. 搭建本地服务器
const为ES6新增量,可以理解为常量,一旦赋值初始化,遍不能修改
引入http模块
创建server,request为发送的请求,response为返回的数据
response.write(‘pachong’);屏幕打印
实质上是node帮我们创建的HTML标签response.end();让响应的代码结束(不可缺)
###### 完整代码
指定9000端口
const http = require('http');
http.createServer((request,response)=>{
response.write('pachong');
response.end();
}).listen(9000);
原文链接: http://enofeng.github.io/2021/07/22/Nodejs爬虫实战(一)/
版权声明: 转载请注明出处.