R
R
Ramil Khismatullin2016-07-31 13:44:23
Python
Ramil Khismatullin, 2016-07-31 13:44:23

VK does not accept captcha (library vk_requests), what should I do?

Hello, I'm a Python beginner and I have a question related to the vk_requests library
When I logged into VK, I started to get CAPTCHA
I tried the vk_requests (InteractiveVKSession) interactive session, and when I needed to enter a captcha, I was given a link to
it program, but the captcha was not accepted
I noticed that when I refresh the captcha page, it changes every time.
What should I do?
Below is the code of the program (I am a beginner programmer, do not judge strictly)

import vk_requests
import time
import copy
import os

print('АВТОРИЗАЦИЯ')
while True:
  user_login = input('Введите ваш логин: ')
  user_password = input('Введите ваш пароль: ')
  try:
    acc = vk_requests.create_api(app_id=5463638, login=user_login, password=user_password, scope=['offline', 'wall'])
    os.system('cls' if os.name == 'nt' else 'clear')
    break
  except:
    print('Неверный логин или пароль :(')

my_group_id = 0
grabber_id = 0
def groups():
  global my_group_id
  global grabber_id
  global new_post
  my_group_id = input('Введите ID вашей группы (цифры): ')
  my_group_id = '-' + my_group_id
  grabber_id = input('Введите ID группы, с которой будут браться посты: ')
  grabber_id = '-' + grabber_id
  if my_group_id != grabber_id:
    new_post = post(my_group_id, grabber_id, words)
  else:
    print('ID групп совпадают!')
    groups()

    
words = ['подпишись', 'заглянуть', 'вступай', 'подписка', 'группу', 'группе', 'группы', 'нажми', 'подписаться', 'групп', 'vk.com', 'продолжение...', 'источнике', 'нажать']
class post:
  def __init__(self, my_group_id, grabber_id, words):
    self.post_id = 0
    self.text = ''
    self.post_attachments = ''
    self.owner_id = grabber_id
    self.my_group_id = my_group_id
    self.counter = 1
    self.try_connection = 0
    self.words = words
  def send_post(self):
    try:
      acc.wall.post(owner_id=self.my_group_id, from_group=1, message=self.text, attachments=self.post_attachments)
      self.post_attachments = ''
      print('Выложен новый пост! [' + str(self.counter) + ']')
      self.counter+=1
    except Exception:
      print('Нет доступа к выкладыванию новостей в данной группе :C')
      groups()
  def get_new_post(self):
    try:
      self.current_post = acc.wall.get(owner_id=self.owner_id).get('items')[0]
      if self.current_post.get('is_pinned') != None:
        self.current_post = acc.wall.get(owner_id=self.owner_id, offset=1).get('items')[0]
      if self.current_post.get('id') != self.post_id and self.current_post.get('copy_history') == None:
        self.m = 0
        for self.elem in self.words:
          if self.elem in self.current_post.get('text').lower():
            self.m+=1
        if self.m == 0:
          self.post_id = self.current_post.get('id')
          self.text = self.current_post.get('text')
          if self.current_post.get('attachments') != None:
            self.current_post_attachments = copy.deepcopy(self.current_post.get('attachments'))
            self.k = 0
            for i in self.current_post_attachments:
              if self.current_post_attachments[self.k].get('type') == 'photo':
                self.media_id = self.current_post_attachments[self.k].get('photo').get('id')
                self.post_attachments = self.post_attachments + ',photo' + self.owner_id + '_' + str(self.media_id)
              if self.current_post_attachments[self.k].get('type') == 'video':
                self.media_id = self.current_post_attachments[self.k].get('video').get('id')
                self.post_attachments = self.post_attachments + ',video' + self.owner_id + '_' + str(self.media_id)
              if self.current_post_attachments[self.k].get('type') == 'audio':
                self.media_id = self.current_post_attachments[self.k].get('audio').get('id')
                self.post_attachments = self.post_attachments + ',audio' + self.owner_id + '_' + str(self.media_id)
              if self.current_post_attachments[self.k].get('type') == 'poll':
                self.media_id = self.current_post_attachments[self.k].get('poll').get('id')
                self.post_attachments =self.post_attachments + ',poll' + self.owner_id + '_' + str(self.media_id)
              self.k+=1
            self.k = 0
          self.send_post()
        self.m = 0
      time.sleep(60)
    except Exception:
      print('Нет доступа к группе с новостями :(')
      for i in range(3):
        try:
          self.get_new_post()
          self.try_connection+=1
        except:
          print('Пытаемся восстановить соединение... [' + str(i + 1) + ']')
        if self.try_connection != 0:
          break
        if i == 2:
          print('Не удалось восстановить подключение')
          print('Проверьте состояние подключения к интернету,\n правильность введенных данных')
          groups()
groups()

while True:
  new_post.get_new_post()
input('Press enter to quit\n')

Here is the library itself.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
OnYourLips, 2016-07-31
@ramil2321

You need to authorize using permitted methods, for example: https://new.vk.com/dev/auth_sites
And only then use the received token for requests.
This library is authorized by an unauthorized method that is dangerous for the user, so VK puts obstacles.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question