I try to login in vk.com, I need some data which is not available in their API (you need to have some sort of Direct Access)
Here is code is so far , i used request(cookies are enabled). I didn't have any success.
const request = require("request");
const cheerio = require('cheerio')
// get login url
function getLoginUrl(callback) {
let j = request.jar()
let options = { method: 'GET',
url: 'https://m.vk.com/login',
jar:j,
}
request(options, function (error, response, body) {
if (error) callback(error);
$= cheerio.load(body);
let url = $('form').attr('action')
callback(null,url)
});
}
// login
function login() {
getLoginUrl(function(err,url){
let j = request.jar()
let options =
{
method: 'POST',
url: url,
headers: {
"Referer":"https://m.vk.com/login?role=fast&to=&s=1&m=1&email=EMail",
"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:50.0) Gecko/20100101 Firefox/50.0"
},
formData: {
email:'email',
pass:'password'
},
jar:j,
followAllRedirects:true,
};
request(options, function (error, response, body) {
if (error) callback(error);
console.log(body)
});
})
}
via user1086010
No comments:
Post a Comment