谁成功了,给个源码 ,我放弃了
谁成功了,给个源码 ,我放弃了
谁成功了,给个源码 ,我放弃了
2016-06-12
var http = require("http");
var querystring = require("querystring");
var postData = querystring.stringify({
content:"hello node.js",
mid:8837
})
var options = {
hostname:"www.imooc.com",
port:80,
path:"/course/docomment",
method:"POST",
headers:{
'Accept':'application/json, text/javascript, */*; q=0.01',
'Accept-Encoding':'gzip, deflate',
'Accept-Language':'zh-CN,zh;q=0.8',
'Connection':'keep-alive',
'Content-Length':postData.length,
'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8',
'Cookie':'私密哦',
'Origin':'http://www.imooc.com',
'Referer':'http://www.imooc.com/video/8837',
'User-Agent':'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36',
'X-Requested-With':'XMLHttpRequest'
}
}
var request = http.request(options,function(res){
console.log("status: "+res.statusCode);
console.log("headers: "+JSON.stringify(res.headers));
res.on('data',function(chunk){
console.log(Buffer.isBuffer(chunk));
console.log(typeof chunk);
})
res.on('end',function(){
console.log("评论完成");
})
})
request.on('error',function(e){
console.log("Error: "+e.message);
})
request.write(postData);
request.end();
var http = require('http');
var querystring = require('querystring');
var postData = querystring.stringify({
'content':'Power By Node.JS',
'mid':8837
})
var options = {
hostname:'www.imooc.com',
port:80,
path:'/course/docomment',
method:'post',
headers:{
'Accept':'application/json, text/javascript, */*; q=0.01',
'Accept-Encoding':'gzip, deflate',
'Accept-Language':'zh-CN,zh;q=0.8,en;q=0.6',
'Connection':'keep-alive',
'Content-Length':postData.length,
'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8',
'Cookie':'改成自己的就OK了!',
'Host':'www.imooc.com',
'Origin':'http://www.imooc.com',
'Referer':'http://www.imooc.com/video/8837',
'User-Agent':'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36',
'X-Requested-With':'XMLHttpRequest'
}
}
var req = http.request(options,function(res){
console.log('status'+res.statusCode);
console.log('headers'+JSON.stringify(res.headers));
res.on('data',function(chunk){
console.log(Buffer.isBuffer(chunk));
console.log(typeof chunk);
})
res.on('end',function(){
console.log('评论完毕!');
})
})
req.on('error',function(e){
console.log('error :'+e.message);
})
req.write(postData)
req.end();
举报