最新回答 / 洛央下
const http = require('http');const hostname = '127.0.0.1';const port = 3000;const server = http.createServer((req, res) => { res.statusCode = 200; res.setHeader('Content-Type', 'text/plain'); res.end('Hello World\n');})server.listen(port, hostname, ...
2016-04-19
爬不到。照着写的没反应'use strict';
var http = require('http');
var url = 'http://www.baidu.com';
http.get(url,function(res){
var html = '';
res.on('data',function(data){
http += data;
});
res.on('end',function(){
console.log(html);
}).on('error',function(){
console.log('获取课程失败,出错啦!');
});
});
var http = require('http');
var url = 'http://www.baidu.com';
http.get(url,function(res){
var html = '';
res.on('data',function(data){
http += data;
});
res.on('end',function(){
console.log(html);
}).on('error',function(){
console.log('获取课程失败,出错啦!');
});
});
2016-04-18