準(zhǔn)備用nodejs搞一個(gè)快速注冊(cè)163郵箱的東西,需要在某一步的時(shí)候post數(shù)據(jù)到https,node的官方文檔實(shí)在太簡(jiǎn)陋了,網(wǎng)上找了個(gè)差不多的例子,拿來(lái)改了改用。
var util = require('util'), https = require('https'); var regUrl = "https://ssl.mail.163.com/regall/unireg/call.do;jsessionid=%s?cmd=register.start&adapter=%s&reforward=common/reform&targetCmd=register.ctrlTop";var cookie = 'a=b;c=d;',mail = 'regUsername', pass = 'password', vcode='abcde';var _regUrl = util.format(regUrl, 'id123455', 'param2'); var post_option = url.parse(_regUrl); post_option.method = 'POST'; post_option.port = 443; var post_data = querystring.stringify({ 'name' : mail, 'uid' : mail+'@163.com', 'confirmPassword' : pass, 'password' : pass, 'vcode' : vcode, 'flow' : 'main', 'from' : '163mail_right', 'mobile' : '', }); post_option.headers = { 'Content-Type' : 'application/x-www-form-urlencoded', 'Content-Length' : post_data.length, Cookie : cookie }; var post_req = https.request(post_option, function(res){ res.on('data', function(buffer){ console.log(buffer.toString()); }); post_req.write(post_data); post_req.end();以上所述就是本文的全部?jī)?nèi)容了,希望大家能夠喜歡。
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注