2

Как правильно решить вопрос с капчей в вк? Для начал мне нужно вывести ссылку на картинку капчи и как-то отправить ответ.

Как допилить мой код?

def add_to_frends():
-friends_list_id = get_friends_list_id() #список ид друзей
-vk = vk_api.VkApi(s_a.L, s_a.P) #vk модуль
-vk.authorization()
-for i in range(1, len(friends_list_id)):
--err = 0
--try:
---rs = vk.method('friends.add', {
---- 'user_id': friends_list_id[i]
--- })
---err = rs
---print(rs)
--except:
---print(err)
--time.sleep(10)
add_to_frends()

Сейчас вылетает такой ужас:

Traceback (most recent call last):
File "/home/mk/.local/lib/python3.5/site-packages/requests/packages/urllib3/connection.py", line 142, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "/home/mk/.local/lib/python3.5/site-packages/requests/packages/urllib3/util/connection.py", line 67, in create_connection
for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):
File "/usr/lib/python3.5/socket.py", line 732, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Temporary failure in name resolution

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/mk/.local/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 578, in urlopen
chunked=chunked)
File "/home/mk/.local/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 351, in _make_request
self._validate_conn(conn)
File "/home/mk/.local/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 814, in _validate_conn
conn.connect()
File "/home/mk/.local/lib/python3.5/site-packages/requests/packages/urllib3/connection.py", line 254, in connect
conn = self._new_conn()
File "/home/mk/.local/lib/python3.5/site-packages/requests/packages/urllib3/connection.py", line 151, in _new_conn
self, "Failed to establish a new connection: %s" % e)
requests.packages.urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno -3] Temporary failure in name resolution

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/mk/.local/lib/python3.5/site-packages/requests/adapters.py", line 403, in send
timeout=timeout
File "/home/mk/.local/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 623, in urlopen
_stacktrace=sys.exc_info()[2])
File "/home/mk/.local/lib/python3.5/site-packages/requests/packages/urllib3/util/retry.py", line 281, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.vk.com', port=443): Max retries exceeded with url: /method/stats.trackVisitor (Caused by NewConnectionError(': Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/mk/Документы/vka/main.py", line 90, in 
add_to_frends()
File "/home/mk/Документы/vka/main.py", line 77, in add_to_frends
vk.authorization()
File "/usr/local/lib/python3.5/dist-packages/vk_api/vk_api.py", line 121, in authorization
if not self.check_token():
File "/usr/local/lib/python3.5/dist-packages/vk_api/vk_api.py", line 329, in check_token
self.method('stats.trackVisitor')
File "/usr/local/lib/python3.5/dist-packages/vk_api/vk_api.py", line 392, in method
response = self.http.post(url, values)
File "/home/mk/.local/lib/python3.5/site-packages/requests/sessions.py", line 518, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/home/mk/.local/lib/python3.5/site-packages/requests/sessions.py", line 475, in request
resp = self.send(prep, **send_kwargs)
File "/home/mk/.local/lib/python3.5/site-packages/requests/sessions.py", line 585, in send
r = adapter.send(request, **kwargs)
File "/home/mk/.local/lib/python3.5/site-packages/requests/adapters.py", line 467, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.vk.com', port=443): Max retries exceeded with url: /method/stats.trackVisitor (Caused by NewConnectionError(': Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))
1
  • как вы исправили эту ошибку, у меня щас такая же жесть вылазет Commented 20 дек. 2017 в 17:21

1 ответ 1

2

Используйте vk-requests. Библиотека реализует обработку капчи в интерактивном режиме, т.е в логах появляется ссылка на капчу и предлагается консольный ввод, всё остальное библиотека берет на себя

Ваш ответ

Нажимая «Отправить ответ», вы соглашаетесь с условиями пользования и подтверждаете, что прочитали политику конфиденциальности.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.