這是一個簡單的我猜: 我想請求一個Node.js
服務器,因爲我目前正在使用cURL。無論我嘗試什麼,我都會從服務器收到錯誤404。使用請求轉換節點js的cURL請求
這裏是我的合法捲曲命令,它會返回一個JavaScript對象:
curl --data "ajax=1&example=test" http://some-site-example.com
閱讀捲曲說明書及申請手冊後,這裏是我在Node.js
嘗試:
request.post({'content-type':'application/x-www-form-urlencoded',ajax:'1',example:'test',url:'http://some-site-example.com'}, function(err, result, body) {
if (err) console.log(err);
else console.log(body);
});
是[要求](HTTPS: //www.npmjs.org/package/request)模塊? – Ravi 2014-10-10 12:19:28