我想通过cs go lounge登录Steam。
手动登录的过程是:
1.按登录按钮重定向到steam website
2.填写用户名和密码。
3.如果有电子邮件验证,您需要输入您收到的特殊代码。
4.返回带有令牌特殊cookie的网站。
现在我想知道如何通过node.js做同样的事情?我想要一些访问cs去休息室数据,但它只有在您登录时才可用。
我尝试使用我的用户名和密码发送表单,但我不明白我得到的回复:
var request = require('request');
var myJSONObject = {
"username" : "username",
"password" : "password",
};
request({
url: "https://steamcommunity.com/openid/login?openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=checkid_setup&openid.return_to=https%3A%2F%2Fcsgolounge.com%2Flogin&openid.realm=https%3A%2F%2Fcsgolounge.com&openid.ns.sreg=http%3A%2F%2Fopenid.net%2Fextensions%2Fsreg%2F1.1&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select",
method: "POST",
json: true,
body: myJSONObject
}, function (error, response, body){
console.log(response);
});
我的回答如下:
{ _readableState:
{ objectMode: false,
highWaterMark: 16384,
buffer: [],
length: 0,
pipes: null,
pipesCount: 0,
flowing: true,
ended: true,
我在Steam页面看到所有字段都在一个表单中(我知道如何从json对象发送POST)但我不知道要发送什么字段,以及如何处理登录的两个步骤(第一个用户名和密码,然后是电子邮件代码) 它一直在继续..
我还尝试从chrome登录并提取cookie并在网站中使用,但又没有运气
var requestify = require('requestify');
var cheerio = require("cheerio");
requestify.get('http://csgolounge.com/trade?t=99441462', {
cookies: {
"domain": "csgolounge.com",
"expirationDate": 1443870461.091163,
"hostOnly": true,
"httpOnly": false,
"name": "token",
"path": "/",
"secure": false,
"session": false,
"storeId": "0",
"value": "0be791e29ba5bd1d839cb4c69bca5ba4",
"id": 8
}
})
.then(function(response) {
var $ = cheerio.load(response.getBody());
console.log($(".buttonright").attr('href'));
}
);
老实说,除了用jquery手动触摸每个按钮外,我没有想法 任何帮助深表感谢。
答案 0 :(得分:0)
当您登录csgolounge时,请检查Google Chrome的网络数据(F12 - >网络)。找到加载页面本身的行,并检查请求标头中发送的Cookie。您尝试在示例中发送错误的Cookie。你需要发送" id"和#34;令牌"带有cookie标题的字段,以便访问csgolounge。