Git Product home page Git Product logo

python3-anticaptcha's Introduction

python3-anticaptcha

Logo

Capsolver

Capsolver.com is an AI-powered service that specializes in solving various types of captchas automatically. It supports captchas such as reCAPTCHA V2, reCAPTCHA V3, hCaptcha, FunCaptcha, DataDome, AWS Captcha, Geetest, and Cloudflare Captcha / Challenge 5s, Imperva / Incapsula, among others.

For developers, Capsolver offers API integration options detailed in their documentation, facilitating the integration of captcha solving into applications. They also provide browser extensions for Chrome and Firefox, making it easy to use their service directly within a browser. Different pricing packages are available to accommodate varying needs, ensuring flexibility for users.


PyPI version Python versions Downloads

Code Climate Codacy Badge codecov

Sphinx docs Build check Installation check Test Lint

Python 3 library for AntiCaptcha service API.

Tested on UNIX based OS.

The library is intended for software developers and is used to work with the AntiCaptcha service API.


If you have any questions, please send a message to the Telegram chat room.

Or email [email protected]


You can check our other projects here - RedPandaDev group. For example - Torrents Tracker bot for Telegram.


How to install?

We recommend using the latest version of Python. python3-anticaptcha supports Python 3.7+.

pip

pip install python3-anticaptcha

How to test?

  1. You need set API_KEY in your environment(get this value from you account).
  2. Run command make tests, from root directory.

Additional info

  1. Library usage examples && Docs
  2. AntiCaptcha errors list

How to get API Key to work with the library

  1. On the page - https://anti-captcha.com/clients/settings/apisetup
  2. Find it: img.png

python3-anticaptcha's People

Contributors

achiciuc avatar andreidrang avatar arkadybag avatar codacy-badger avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar maximium avatar namdevel avatar pilipranks avatar pyup-bot avatar redv0id avatar suroegin avatar wandersoncferreira avatar yuego avatar ziavra 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python3-anticaptcha's Issues

selenium_recaptcha_v2.py works on google.com demo but not on actual site

Hello,

I'm trying to login to one site where i can check for my bills. It uses recaptcha unfortunately ... For test purposes, I copied the exact selenium_recaptcha_v2.py script and added my API_KEY, when got to part:

browser.execute_script("arguments[0].click();", post_button)
i issued browser.page_source and noticed that it was successful.

However when i tried on real live site (i will post the site if requested) it fails to do so, site thinks that i have never clicked on recaptcha form. Ofcourse i have verified and when necessary edited lines

post_xpath = '//*[@id="recaptcha-demo-submit"]'

and
recaptcha_xpath = '//*[@id="g-recaptcha-response"]'

to match the site source.
When i eventually try and execute everything, site just says that recaptcha was not submitted.
Any idea what else i need to look into to make this work?

Проблемы при скачивании картинки средствами библиотеки в асинхронном режиме

Describe the bug
При вызове ImageToTextTask.aioImageToTextTask с параметрами save_format="const" и captcha_link="...." скачивается и отправляется неполная картинка.

To Reproduce
Steps to reproduce the behavior:

async def run():
    try:
        resolve = await ImageToTextTask.aioImageToTextTask(
            anticaptcha_key=ANTICAPTCHA_KEY, save_format="const"
        ).captcha_handler(
            captcha_link="http://www.list-org.com/kcap.php?PHPSESSID=ahaisngr4lh63to9itqn9n85m6"
        )

        print(resolve)

    except Exception as err:
        print(err)


if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(run())
    loop.close()

Expected behavior
Получить полную картинку.

Desktop (please complete the following information):

  • OS: Microsoft Windows [Version 10.0.18362.329]
  • python3-anticaptcha 1.5.1
  • python 3.7.3

Posting Request With Selenium

Hello and thanks for this wrapper. I've tried to post the request I get using Selenium, but the webpage is unaffected. Am I doing something wrong?

from seleniumrequests import Firefox
DRIVER = Firefox()
DRIVER.request('POST', PAGE_URL, data={'g-recaptcha-response': user_answer})

where page url, and user answer are correctly defined.
Printing response gives me 200, but when I check selenium, the captcha isn't solved.

site key is always wrong

###Short description of trouble. Краткое описание проблемы.
Site key always wrong
###Full description of trouble. Полное описание проблемы.
the site key is always wrong when trying to get the captcha_key answer = ReCaptchaV3TaskProxyless.ReCaptchaV3TaskProxyless(anticaptcha_key=anticaptchakey)\ .captcha_handler( websiteURL="https://discordapp.com/register", websiteKey="6Lef5iQTAAAAAKeIvIY-DeexoO3gj7ryl9rLMEnn", minScore=0.3, pageAction="link_page", )

NoCaptchaTaskProxyless - ResourceWarning

When I execute several processes to resolve recaptchas, I am issued this warning and it continues to work.

/python3.6/site-packages/python3_anticaptcha/NoCaptchaTaskProxyless.py:98: ResourceWarning: unclosed <socket.socket fd=23, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('xxx.xxx.xxx.xxx', 52936), raddr=('209.212.146.169', 443)
result_payload=self.result_payload, sleep_time=self.sleep_time

  • OS: Debian 9
  • Python 3.6.4
  • python3-anticaptcha 1.2.5
  • requests 2.21.0
  • aiohttp 3.5.4
  • pika 1.0.1

Plan

  • Добавить параметр для callback'a
  • Добавить корректный отлов ошибок и возвращение результата

Добавить методы:

  • FunCaptchaProxyless
  • SquareNetTextTask
  • GeeTestTask
  • GeeTestTaskProxyless
  • CustomCaptchaTask

Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="recaptcha-demo-submit"]"}

Не решает рекапчу 2-ую. Использую скрипт который есть в репозитории. Сайт - idealo.de

import time

from selenium import webdriver

from python3_anticaptcha.NoCaptchaTaskProxyless import NoCaptchaTaskProxyless

ANTICAPTCHA_KEY = "xxx"
WEB_URL = "https://www.idealo.de/"
SITE_KEY = "6LdAKg4TAAAAACsbrjT4aMumPbLZCz-6pslszlrQ"

post_xpath = '//*[@id="recaptcha-demo-submit"]'
recaptcha_xpath = '//*[@id="g-recaptcha-response"]'

# setup selenium
browser_options = webdriver.ChromeOptions()
# browser_options.headless = True
browser_options.add_argument("--disable-gpu")
browser_options.add_argument("--no-sandbox")
browser_options.add_argument("disable-infobars")
browser_options.add_argument("--disable-extensions")
# run browser
browser = webdriver.Chrome(executable_path="chromedriver.exe", options=browser_options)
# open page
browser.get(WEB_URL)
# prepare captcha solver
captcha_obj = NoCaptchaTaskProxyless(anticaptcha_key=ANTICAPTCHA_KEY)
# solve recaptcha
browser.execute_script("document.getElementById('g-recaptcha-response').style.display = 'block';")
# wait script finish
time.sleep(1)
recaptcha_element = browser.find_element_by_xpath(recaptcha_xpath)
recaptcha_element.click()
recaptcha_element.clear()
# get captcha solution
captcha_result = captcha_obj.captcha_handler(websiteURL=WEB_URL, websiteKey=SITE_KEY)
# insert captcha solution
recaptcha_element.send_keys(captcha_result["solution"]["gRecaptchaResponse"])
# wait success insertion
time.sleep(2)
# push post button
post_button = browser.find_element_by_xpath(post_xpath)
browser.execute_script("arguments[0].click();", post_button)
# OR
# post_button.click()

time.sleep(5)
browser.quit()

Don't use tight requirements

Hey.
As you may know python's new package dependency resolver is going to change and be strict about conflicting package dependencies.
The current requirements are too strict and I don't think they are needed.

Custom Captcha

###Short description of trouble. Краткое описание проблемы.

hello . i want use custom captcha so i got this doc https://python-anticaptcha.readthedocs.io/en/latest/fields.html

from python_anticaptcha import AnticaptchaClient, ImageToTextTask,CustomCaptchaTask
when i import i got
cannot import name 'CustomCaptchaTask' from 'python_anticaptcha'

any doc for custom captcha ? or is'nt yet supported ?
###Full description of trouble. Полное описание проблемы.

Wrong errors.py file packed in dist/python3-anticaptcha-1.2.1.tar.gz

Describe the bug
python3_anticaptcha/errors.py file in git and distribution archive are different.

To Reproduce
Steps to reproduce the behavior:
0. You're in your python3-anticaptcha repo dir

  1. git checkout 1.2.1
  2. tar xzf dist/python3-anticaptcha-1.2.1.tar.gz -C /tmp/unpacked_dist
  3. diff /tmp/unpacked_dist/python3_anticaptcha/errors.py python3_anticaptcha/errors.py

How to use with Selenium and Chrome

###Short description of trouble. Краткое описание проблемы
I want to login in to the site swagbucks.com.
###Full description of trouble. Полное описание проблемы.
I guess I need to Inject/send the result token in some way to make it work.
Any help how to use the result token with selenium/chrome?

отсутствует параметр в методе captcha_handler

###Short description of trouble. Краткое описание проблемы.
отсутствует параметр в методе
###Full description of trouble. Полное описание проблемы.
`Base64 files
Пример работы с передачей файла капчи уже закодированного в base64
An example of working with captcha file already encoded in base64
"""

закодировано: 976979

base_64_file = open('base64image.txt', 'rb')

user_answer_base64 = ImageToTextTask.ImageToTextTask(anticaptcha_key=ANTICAPTCHA_KEY).captcha_handler(captcha_base64=base_64_file)

print(user_answer_base64)
`
captcha_base64 нет такого параметра у метода

Enable to submit Google Recaptcha

Hello, first of all, thank you for your great work here!

Okay, so I'm creating a account sign up bot using python, and everything work just fine but when I submit the captcha, it return "Verification unsuccessful. Please try again."

I tried many way but still cannot figure it out why is this happening. Can you point me out where my mistake? Thank you so much.
Here is the callback script of the site for submitting captcha since it doesnt have the submit button.

function attachChoiceHandlers(markupId, callbackScript) { var inputNodes = wicketGet(markupId).getElementsByTagName('input'); for (var i = 0 ; i < inputNodes.length ; i ++) { var inputNode = inputNodes[i]; if (!inputNode.type) continue; if (!(inputNode.className.indexOf('wicket-'+markupId)>=0)&&!(inputNode.id.indexOf(markupId+'-')>=0)) continue; var inputType = inputNode.type.toLowerCase(); if (inputType == 'checkbox' || inputType == 'radio') { Wicket.Event.add(inputNode, 'click', callbackScript); } } }

This is the reCaptcha element:

<textarea id="g-recaptcha-response-1" name="g-recaptcha-response" class="g-recaptcha-response" style="width: 250px; height: 40px; border: 1px solid rgb(193, 193, 193); margin: 10px 25px; padding: 0px; resize: none; display: none;"></textarea>

My code for captcha handle:

site_key = self.driver.find_element_by_id("g-recaptcha-panel").get_attribute("data-sitekey")
cap_url = self.driver.find_elements_by_tag_name("iframe")[0].get_attribute("src")
client = AnticaptchaClient(self.ac_token)
task = NoCaptchaTaskProxylessTask(cap_url, site_key)
job = client.createTask(task)
print("Submitting Captcha")
job.join()
response = job.get_solution_response()
print("Submited Captcha", response)
wait(0.5)
self.driver.execute_script('document.getElementById("g-recaptcha-response").innerHTML = "%s"' % response)
wait(2)
self.driver.execute_script("x = document.getElementsByTagName('input')[0];"
"x.click();")
wait(3)
self.driver.find_element_by_class_name("InputSubmit").click()

Token - Form submission returning "captcha wrong"

First, thank's for this library.

I'm using the following code to bypass a "Recaptcha":

                ANTICAPTCHA_KEY = ''
                PAGE_URL = url
                SITE_KEY = site_key

                result = NoCaptchaTaskProxyless.NoCaptchaTaskProxyless(anticaptcha_key = ANTICAPTCHA_KEY)\
                .captcha_handler(websiteURL=PAGE_URL,
                             websiteKey=SITE_KEY)
                captcha_answer = result.get("solution").get("gRecaptchaResponse")
                if captcha_answer != "":
                    print(captcha_answer)
                    self.driver.execute_script("document.getElementById('g-recaptcha-response').focus()")
                    time.sleep(2)
                    self.driver.execute_script("document.getElementById('g-recaptcha-response').innerHTML='%s'" % captcha_answer)
                    time.sleep(2)
                    nextBtn = self.driver.find_element_by_xpath("//input[@value='Avançar']")
                    nextBtn.click()

Problem: After click the button to submit the form, the page returns an error concerning the "Captcha wrong".

Can someone help me ?

Initial Update

The bot created this issue to inform you that pyup.io has been set up on this repo.
Once you have closed it, the bot will open pull requests for updates as soon as they are available.

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.