var http = require('http');
var querystring = require('querystring');
var postData = querystring.stringify({
'content': '表白老师表白老师表白老师表白老师',
'mid': 8837
})
var options = {
hostname: 'www.imooc.com',
method: 'POST',
port: 80,
path: '/course/docomment',
headers: {
'Accept': 'application/json, text/javascript, */*; q=0.01',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,ru;q=0.7,es;q=0.6',
'Connection': 'keep-alive',
'Content-Length': postData.length,
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Cookie': 'imooc_uuid=adb2e7b3-7efb-41d8-a346-ae32a0066618; imooc_isnew_ct=1506047932; loginstate=1; apsid=k4NGZkZmIyNWQ0N2Q1YzM3MDc4NzNmNTViZTJmMGMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANjE1MDkzOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADYzMGRhNTk2ZmJmNjcwZTM2MzNlOTU0OTQyMzgyOTlmvyMUWr8jFFo%3DMT; PHPSESSID=rqflnitusjio13vqgvu7l9o800; IMCDNS=0; Hm_lvt_f0cfcccd7b1393990c78efdeebff3968=1511269306,1511424414,1511428174; Hm_lpvt_f0cfcccd7b1393990c78efdeebff3968=1511443098; imooc_isnew=2; cvde=5a16819b9b600-144',
'Host': 'www.imooc.com',
'Origin': 'https://www.imooc.com',
'Referer': 'https://www.imooc.com/video/8837',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36',
'X-Requested-With': 'XMLHttpRequest'
}
}
var req = http.request(options, function (res) {
console.log('status:' + res.statusCode);
console.log('header', JSON.stringify(res.headers))
res.on('data', function (chunk) {
console.log(Buffer.isBuffer(chunk));
})
res.on('end', function () {
console.log('发布成功!');
})
})
req.on('error', function (error) {
console.log(error.message);
})
req.write(postData);
req.end();
PS:一直报这个错!!QAQ
ruibin
脚本小布
相关分类