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
- java post 請求Java
- axios 發get,post 請求小結iOS
- post 請求工具類
- SpringMVC中如何傳送GET請求、POST請求、PUT請求、DELETE請求。SpringMVCdelete
- Postman傳送Post請求Postman
- Java 監聽POST請求Java
- requests 模組 - post 請求
- Java傳送Post請求Java
- 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
- ajax中POST請求與引數(請求體)設定
- 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
- linux用curl傳送post請求Linux
- get,post URL加字尾請求
- 小程式https請求,http網站升到httpsHTTP網站
- Python中get、post請求詳解(HTTP請求頭、狀態碼)PythonHTTP
- Java用HttpClient3傳送http/https協議get/post請求,傳送map,jsoJavaHTTPclient協議JS
- C#模擬HTTP請求Post JSONC#HTTPJSON
- 如何使用post請求下載檔案