Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const axios = require('axios');
- const qs = require("querystring");
- axios.defaults.headers.common['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8';
- axios.defaults.headers.common['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36';
- axios.defaults.headers.common['Content-Type'] = 'application/x-www-form-urlencoded';
- const vk = axios.create({
- withCredentials: true
- });
- (async() => {
- // Получаем главную страницу, чтобы справсить параметры ip_h и lg_h
- const main_page = await vk.get('https://vk.com');
- let ip_h = null;
- let lg_h = null;
- let to = null;
- if (match = /name="ip_h" value="([a-zA-Z0-9]*)"/.exec(main_page.data)) {
- ip_h = match[1];
- }
- if (match = /name="lg_h" value="([a-zA-Z0-9]*)"/.exec(main_page.data)) {
- lg_h = match[1];
- }
- if (match = /,"to":"([a-zA-Z0-9]*)","/.exec(main_page.data)) {
- to = match[1];
- }
- //console.log(main_page.data)
- console.debug(`ip_h => ${ip_h}, lg_h => ${lg_h}, to => ${to}`);
- //return;
- const res = await vk.post('https://login.vk.com/?act=login',
- qs.stringify({
- 'act': 'login',
- 'role': 'al_frame',
- 'expire': '',
- 'to': to,
- 'recaptcha': '',
- 'captcha_sid': '',
- 'captcha_key': '',
- '_origin': 'https://vk.com',
- 'ip_h': ip_h,
- 'lg_h': lg_h,
- 'ul': '',
- 'email': '+79617370099',
- 'pass': 'LagySy123'
- }), {
- headers: {
- Cookie: main_page.headers["set-cookie"]
- }}
- );
- //console.log(res);
- console.log(res.headers)
- //console.log(res.headers["set-cookie"]);
- const page = await axios.get('https://vk.com/adsmarket', {
- withCredentials: true,
- headers: {
- Cookie: res.headers["set-cookie"]
- }
- });
- console.log(page.data)
- })();