nodejs實現HTTPS發起POST請求
準備用nodejs搞一個快速註冊163郵箱的東西,需要在某一步的時候post資料到https,node的官方文件實在太簡陋了,網上找了個差不多的例子,拿來改了改用。
[JavaScript] 純文字檢視 複製程式碼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();
相關文章
- POST發起下載請求
- vue 發起get請求和post請求Vue
- python3 實現 get 和 post 請求Python
- cURL實現傳送Get和Post請求(PHP)PHP
- 原生js實現Ajax請求,包含get和postJS
- java post 請求Java
- axios 發get,post 請求小結iOS
- post 請求工具類
- SpringMVC中如何傳送GET請求、POST請求、PUT請求、DELETE請求。SpringMVCdelete
- node.js的express模組實現GET和POST請求Node.jsExpress
- Postman傳送Post請求Postman
- Java 監聽POST請求Java
- requests 模組 - post 請求
- Java傳送Post請求Java
- 騰訊雲:免費SSL證書實現https請求HTTP
- Charles 代理https請求HTTP
- get請求和post請求的區別
- python傳送HTTP POST請求PythonHTTP
- post請求帶來的option
- axios的post請求爬坑iOS
- SpringCloud OpenFeign Post請求的坑SpringGCCloud
- uniapp之post請求如何用APP
- POST與GET請求區別
- axios.pacth () 請求如何發起?iOS
- HTTP協議如何發起請求HTTP協議
- golang使用fasthttp 發起http請求GolangASTHTTP
- NodeJS Https HSM雙向認證實現NodeJSHTTP
- ajax中POST請求與引數(請求體)設定
- 跟我一起動手實現Tomcat(三):解析Request請求引數、請求頭、cookieTomcatCookie
- uni-app的POST請求和GET請求APP
- shell妙用 —— 發post請求重新整理CDN快取快取
- React Native請求Https請求不通怎麼解決React NativeHTTP
- vue2.0 axios post請求傳參問題(ajax請求)VueiOS
- windows中使用cmd發起http請求WindowsHTTP
- get與post的請求區別
- python介面測試—post請求(二)Python
- Java Http Get Post 請求工具類JavaHTTP
- go對get、post請求封裝Go封裝
- java傳送GET和post請求Java