PC端評論接口:
多說: http://duoshuo.com/
暢言: http://changyan.kuaizhuan.com
//評論功能
var http = require('http')
var querystring = require('querystring')
var postData = querystring.stingify({
'content' : '評論',
//提交的ID 在表單數(shù)據(jù):查看mid
'cid': 8837
})
var options = {
hostname: 'www.imooc.com',
port:80,
//路徑 查看消息頭: 請求網(wǎng)址
path:'/course/ajaxmediauser',
method:'POST',
headers:{
'Host':'www.imooc.com',
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0',
'Accept':'application/json, text/javascript, */*; q=0.01',
'Accept-Language':'zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3',
'Accept-Encoding':'gzip, deflate'
'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8',
'X-Requested-With':'XMLHttpRequest',
'Referer':'http://www.imooc.com/video/8837',
'Content-Length':'46',
'Connection':'keep-alive',
'Pragma':'no-cache',
'Cache-Control':'no-cache'
}
}
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()