Answer the question
In order to leave comments, you need to log in
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
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question