S
S
Sanders Rocket2020-03-17 05:41:55
Python
Sanders Rocket, 2020-03-17 05:41:55

VK API Python subscriptions?

Hello everyone
, we have the following code:

import vk_api
import os, sys
import requests

if sys.platform.lower() == "win32":
    os.system('color')

class color:
    HEADER = '\033[95m'
    blue = '\033[94m'
    green = '\033[92m'
    WARNING = '\033[93m'
    red = '\033[91m'
    end = '\033[0m'
    bold = '\033[1m'
    UNDERLINE = '\033[4m'

prx = 0;

while not prx:
    a = input(f'{color.bold}{color.blue}>> {color.end}Название файла с аккаунтами: ')

    try:
        with open(a) as file:
            prx = [row.strip() for row in file]
    except:
        print(f'{color.bold}{color.red}<< {color.end}Не удалось найти файл с аккаунтами{color.end}')

b = input(f'{color.bold}{color.blue}>> {color.end}Введите идентификатор группы: ')
print ('')

total = 0;
errors = 0;

def captcha_handler(captcha):
    key = input(f">> {color.bold}{color.red}Введите капчу (Link: {captcha.get_url()}: ")
    return captcha.try_again(key)

for i in range(len(prx)):
    try:
        a = prx[i].split(':', maxsplit = 1)
        vk_session = vk_api.VkApi(a[0], a[1], captcha_handler=captcha_handler)
        vk_session.auth()
        vk = vk_session.get_api()
        vk.groups.join(group_id = b)
        total += 1
        print(f'{color.bold}{color.green}>> {color.end}{a[0]} — вкид оформлен успешно!{color.end}')
    except vk_api.VkApiError as clown:
        print(f'{color.bold}{color.red}<< {color.end}{a[0]} — неизвестная ошибка {color.end}{color.red}{color.bold}{clown}{color.end}')
    except vk_api.exceptions.AuthError: # Ошибка авторизации
        print(f'{color.bold}{color.red}<< {color.end}{a[0]} — ошибка при авторизации{color.end}')
        errors += 1
    except vk_api.exceptions.BadPassword: # Неверный пароль
        print(f'{color.bold}{color.red}<< {color.end}{a[0]} — неверный пароль{color.end}')
        errors += 1
    except vk_api.exceptions.AccountBlocked: # Аккаунт заблокирован
        print(f'{color.bold}{color.red}<< {color.end}{a[0]} — аккаунт заблокирован{color.end}')
        errors += 1
    except vk_api.exceptions.TwoFactorError: # Двухфакторка
        print(f'{color.bold}{color.red}<< {color.end}{a[0]} — на аккаунте двухфакторная аутентификация{color.end}')
        errors += 1
    except vk_api.exceptions.SecurityCheck: # Ошибка безопасности
        print(f'{color.bold}{color.red}<< {color.end}{a[0]} — ошибка безопасности{color.end}')
        errors += 1;
    except vk_api.exceptions.Captcha as captcha:
        print(f'{color.bold}{color.red}<< {color.end}{a[0]} — необходимо ввести капчу{color.end}')
    except:
        print(f'{color.bold}{color.red}<< {color.end}Неизвестная ошибка{color.end}')
        errors += 1

Further we have such an error -
MW2X2Uh.png
What do you need? You need to either fix the error, or tell me how to authorize accounts without a phone number

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrew, 2019-08-14
@Yourmind

This is a known issue
Use psycopg2 instead of python-postgres

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question