Giter Club home page Giter Club logo

python-rucaptcha's Introduction

python-rucaptcha's People

Contributors

andreidrang avatar codacy-badger avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar loadi avatar nenkoru avatar nuklea avatar pyup-bot avatar redv0id avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-rucaptcha's Issues

Report issue

Server always returns ERROR_WRONG_CAPTCHA_ID, but captcha id is definitely correct

Connections issue with 2captcha

###Short description of trouble. Краткое описание проблемы.
Hello there is connection problems with the api it produces Remote end closed connection without response error and sometimes it works but once this error starts its like this forever

###Full description of trouble. Полное описание проблемы.

When i ran the program it sometimes works and sometimes produces this error and when it does its stuck forever i searched online and found this

https://stackoverflow.com/questions/48105448/python-http-server-client-remote-end-closed-connection-without-response-error

but i dont have expereince in dealing with http/networks so would be helpfull if you fix it

this is not an idea , it's a question.

hello i'm trying to create a tiktok plays pokemon and it works like in a 50% i think... this bot can avoid the captcha of the tiktok livestream software? i mean.. if i'm streaming like 4 or 5 hours it appears a captcha on the screen and if i don't solve it the stream finish.

can this bot solve this captcha? i want to be 24/7 streaming my project but i don't know how to avoid that :(

thanks a lot for any reply and sorry if i'm spamming and for my poor english (english is not my native language so i do the best i can)

best regards :)

Тестирование библиотеки

Создать сайт(модуль ещё один?), на котором будут выводиться все виды капчи и их юзать для тестирования библиотеки.

cx_Freeze

creating directory build_windows\lib
python_rucaptcha not added to project...
Most likely there is not enough file init.py

Исключения

После того, как будут реализованы все метода API - нужно сделать нормальный "отлов" ошибок/исключений.

Не использовать диск в ImageCaptcha.py

Смотрю ImageCaptcha.py, в ней вы постоянно используете диск для сохранения файлов (не знаю чем это обусловленно), но не могли бы вы добавить метод работы без него.

Пример подобного кода:

image = io.BytesIO()

try:
    r = requests.get(link, stream=True)
    r.raise_for_status()

    for chunk in r.iter_content(1024):
        image.write(chunk)
except requests.exceptions.RequestException as e:
    print("Что то пошло не так")

image.seek(0)

Error: Max retries exceeded with url: /res.php

Из-за ошибки в модуле падают автономные скрипты его использующие, что критично. Падает с ошибкой requests.exceptions.ConnectionError: HTTPConnectionPool(host='rucaptcha.com', port=80): Max retries exceeded with url: /res.php

Алгоритм скрипта простой и последовательный: запрос к сайту для взятия капчи, сохранение её в файл (captcha_file), запрос на rucaptcha и получение ответа, отдача ответа на сайт (функция ниже).
sleep_time выставлен в 5, согласно документации api. (Кстати, может стоит прописать 5 по умолчанию, это минимальное значение у них.)

И ещё хотелось бы, чтобы отдавался код этой ошибки. А то нет ни кода предупреждений от rucaptcha, и сама ошибка валится глобально по requests.exceptions.ConnectionError... И не понять чем именно превышен лимит.
Также не понятно, это бан аккаунта на 5-10 минут, или без бана?

Функция:

def send_captcha_for_solve(captcha_link=None, captcha_file=None):
    print('Sending captcha to the solve service')

    answer = ImageCaptcha.ImageCaptcha(rucaptcha_key=RUCAPTCHA_KEY, 
service_type='rucaptcha', sleep_time=5) \
        .captcha_handler(captcha_link=captcha_link, captcha_file=captcha_file)
    if answer['errorId'] == 0:
        print('text: %s, taskId: %s' % (answer['captchaSolve'], answer['taskId']))
        return answer
    elif answer['errorId'] == 1:
        print('errorId: %s, errorBody: %s' % (answer['errorId'], answer['errorBody']))
Loading captcha from site
Saving to captcha.jpg
Sending captcha to the solve service
Traceback (most recent call last):
File "C:\Users\Artem\Anaconda3\lib\site-packages\urllib3\connection.py", line 141, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "C:\Users\Artem\Anaconda3\lib\site-packages\urllib3\util\connection.py", line 83, in create_connection
raise err
File "C:\Users\Artem\Anaconda3\lib\site-packages\urllib3\util\connection.py", line 73, in create_connection
sock.connect(sa)
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Artem\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 601, in urlopen
chunked=chunked)
File "C:\Users\Artem\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 357, in _make_request
conn.request(method, url, **httplib_request_kw)
File "C:\Users\Artem\Anaconda3\lib\http\client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Users\Artem\Anaconda3\lib\http\client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Users\Artem\Anaconda3\lib\http\client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Users\Artem\Anaconda3\lib\http\client.py", line 1026, in _send_output
self.send(msg)
File "C:\Users\Artem\Anaconda3\lib\http\client.py", line 964, in send
self.connect()
File "C:\Users\Artem\Anaconda3\lib\site-packages\urllib3\connection.py", line 166, in connect
conn = self._new_conn()
File "C:\Users\Artem\Anaconda3\lib\site-packages\urllib3\connection.py", line 150, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x00000174B0744898>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Artem\Anaconda3\lib\site-packages\requests\adapters.py", line 440, in send
timeout=timeout
File "C:\Users\Artem\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "C:\Users\Artem\Anaconda3\lib\site-packages\urllib3\util\retry.py", line 388, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='rucaptcha.com', port=80): Max retries exceeded with url: /res.php (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x00000174B0744898>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "statuz03.py", line 316, in <module>
process_page(compId, wrong_ids)
File "statuz03.py", line 266, in process_page
process_page(compId, wrong_ids)
File "statuz03.py", line 254, in process_page
captchaAnswer = send_captcha_for_solve(captcha_file=captcha_path)
File "statuz03.py", line 38, in send_captcha_for_solve
.captcha_handler(captcha_link=captcha_link, captcha_file=captcha_file)
File "C:\Users\Artem\Anaconda3\lib\site-packages\python_rucaptcha\ImageCaptcha.py", line 207, in captcha_handler
captcha_response = requests.post(self.url_response, data=self.get_payload)
File "C:\Users\Artem\Anaconda3\lib\site-packages\requests\api.py", line 112, in post
return request('post', url, data=data, json=json, **kwargs)
File "C:\Users\Artem\Anaconda3\lib\site-packages\requests\api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\Artem\Anaconda3\lib\site-packages\requests\sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\Artem\Anaconda3\lib\site-packages\requests\sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "C:\Users\Artem\Anaconda3\lib\site-packages\requests\adapters.py", line 508, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='rucaptcha.com', port=80): Max retries exceeded with url: /res.php (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x00000174B0744898>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond',))

Лицензия

День добрый,
может придираюсь, но у вас файле setup.py лицензия MIT, а в репозитории AGPL-3.0

Коды ошибок

Можешь добавить, чтобы возвращался не только текст сообщения, но и код ошибки типа int? Вроде if answer['errorCode'] == 1001:.
Проще было бы обрабатывать. Сейчас какая ошибка надо выяснять, парся текстовую строку ['errorBody'], что довольно необычно.

Имхо, лучше выдавать в ['errorId']. Но тогда может быть глюк совместимости, у текущих пользователей использующих ['errorId'] == 1.

AttributeError: 'aioReCaptchaV2' object has no attribute 'url_request'

Describe the bug
Exception on the last version of the package.

File "/home/nokados/anaconda3/lib/python3.6/site-packages/python_rucaptcha/ReCaptchaV2.py", line 222, in captcha_handler
    async with session.post(self.url_request, data = self.post_payload) as resp:
AttributeError: 'aioReCaptchaV2' object has no attribute 'url_request'

To Reproduce

user_answer = await ReCaptchaV2.aioReCaptchaV2(rucaptcha_key=RUCAPTCHA_KEY).captcha_handler(site_key=site_key,
                                                                                   page_url=self.driver.get_url())

Expected behavior
No exception, like in 2.5

Library version
2.6.1, 2.6, 2.5.4 (Maybe etc)

need to post the answer?

###Short description of trouble. Краткое описание проблемы.
As you know, there are a million completely different sites that request the answer in completely different fields, using this system, will I still need to differentiate all the sites?

###Full description of trouble. Полное описание проблемы.
The question may sometimes be obvious to you, but I don't really get it right, because in the code examples you put in, there is no input from the captcha answer, so I would like to know if it is automatically resolved or if I have to fill it in the input field of the response after acquiring it. Note: I will need to use Captcha, ReCaptcha and Geetest

Вопрос по коду

Код из ReCaptchaV2.py

def captcha_handler(self, site_key: str, page_url: str, **kwargs):
    # Если переданы ещё параметры - вносим их в get_payload ???
    if kwargs:
        for key in kwargs:
            self.get_payload.update({key: kwargs[key]})

    self.post_payload.update({"googlekey": site_key, "pageurl": page_url})
    # получаем ID капчи
    captcha_id = requests.post(self.url_request, data=self.post_payload).json()

Для чего дополнительные параметры запроса по типу (cookie, userAgent, proxy) заносить в get_payload, если их нам нужно отправить?

Поддердка proxy в ReCaptcha v2

На данный момент в библиотеке отсутствует поддержка прокси серверов в функции ReCaptchaV2.ReCaptchaV2. Без чего, в случае работы через прокси, решение капчи не имеет смысла

Краткий план действий

  • Добавить модуль для callback

  • Допилить API сайта

  • Тесты для API сайта

  • Вынести получение решения капч в отдельный модуль

  • Добавить возможность прерывать выполнение действий, до получения решения капчи и дать возможность получать ответ на капчу через отдельный модуль

  • Перевести документацию на английский

  • Тесты для методов решения капчи

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.