課程
/前端開發
/Node.js
/進擊Node.js基礎(一)
誰成功了,給個源碼 ,我放棄了
2016-06-12
源自:進擊Node.js基礎(一) 5-12
正在回答
var http = require("http");
var querystring = require("querystring");
var postData = querystring.stringify({
content:"hello node.js",
mid:8837
})
var options = {
hostname:"www.xianlaiwan.cn",
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.xianlaiwan.cn',
'Referer':'http://www.xianlaiwan.cn/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();
qq_我禿了也變強了_0 提問者
https://github.com/cllgeek/movie-project? ? 上有源碼
var http = require('http');
var querystring = require('querystring');
?
? ? 'content':'Power By Node.JS',
? ? 'mid':8837
? ? hostname:'www.xianlaiwan.cn',
? ? 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.xianlaiwan.cn',
? ? ? ? 'Origin':'http://www.xianlaiwan.cn',
? ? ? ? 'Referer':'http://www.xianlaiwan.cn/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();
Post請求體的?
同求, 推薦給出源碼.
舉報
本視頻教程帶你揭開Node.js的面紗,帶你走進一個全新世界
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2016-06-22
var http = require("http");
var querystring = require("querystring");
var postData = querystring.stringify({
content:"hello node.js",
mid:8837
})
var options = {
hostname:"www.xianlaiwan.cn",
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.xianlaiwan.cn',
'Referer':'http://www.xianlaiwan.cn/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();
2016-06-25
https://github.com/cllgeek/movie-project? ? 上有源碼
2016-06-13
var http = require('http');
var querystring = require('querystring');
?
var postData = querystring.stringify({
? ? 'content':'Power By Node.JS',
? ? 'mid':8837
})
?
var options = {
? ? hostname:'www.xianlaiwan.cn',
? ? 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.xianlaiwan.cn',
? ? ? ? 'Origin':'http://www.xianlaiwan.cn',
? ? ? ? 'Referer':'http://www.xianlaiwan.cn/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();
2016-06-12
Post請求體的?
2016-06-12
同求, 推薦給出源碼.