两篇参考文章~ 希望对node比较熟悉的人帮帮忙~ 用node-webkit 做一个模拟百度登陆的工具
c# 模拟百度登陆
http://www.51joben.com/archives/7151.html
php 模拟百度登陆
http://www.qaulau.com/php-simulated-login-baidu/
直接使用已登录用户的cookie
用nodejs http.request
模拟登陆 简单来说就是模拟发送http请求
exports.sendEmail = function (req, res) {
var data = {
address: 'test@test.com',
subject: "test"
};
data = require('querystring').stringify(data);
console.log(data);
var opt = {
method: "POST",
host: "localhost",
port: 8080,
path: "/v1/sendEmail",
headers: {
"Content-Type": 'application/x-www-form-urlencoded',
"Content-Length": data.length
}
};
var req = http.request(opt, function (serverFeedback) {
if (serverFeedback.statusCode == 200) {
var body = "";
serverFeedback.on('data', function (data) { body += data; })
.on('end', function () { res.send(200, body); });
}
else {
res.send(500, "error");
}
});
req.write(data + "\n");
req.end();
}
上面是我原来写过的一个功能。可以参照下
注意在模拟登陆的时候把用户的cookie要写到headers中去
为什么要使用node-webkit呢?
直接使用node的http.request API就可以了
传入必要的参数,发送http请求,获取返回的结果