NoahCardoza / CaptchaHarvester

Solve captchas yourself without having to pay for services like 2captcha for use in automated projects.
https://pypi.org/project/captcha-harvester/
MIT License
662 stars 63 forks source link

question about usage #20

Closed azamet90 closed 4 years ago

azamet90 commented 4 years ago
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from python_anticaptcha import AnticaptchaClient, NoCaptchaTaskProxylessTask
import time
from harvester import fetch

server_address = ('127.0.0.1', 5000)
token = fetch.token(server_address)
url = "https://emailondeck.com"
driver = webdriver.Firefox()
driver.implicitly_wait(30)
driver.get(url)

wait = WebDriverWait(driver, 30)
api_key = token
site_key = '6LeQLyEUAAAAAKTwLC-xVC0wGDFIqPg1q3Ofam5M'  # grab from site

client = AnticaptchaClient(api_key)
task = NoCaptchaTaskProxylessTask(url, site_key)
job = client.createTask(task)
print("Waiting to solution by Anticaptcha workers")
print('Token:', token)
job.join()
# Receive response
response = job.get_solution_response()
print("Received solution", response)

# Inject response in webpage
driver.execute_script('document.getElementById("g-recaptcha-response").innerHTML = "%s"' % response)

# Wait a moment to execute the script (just in case).
time.sleep(1)

# Press submit button
driver.find_element_by_xpath('//*[@id="get_email_btn"]').click()
/home/azamet/Belgeler/projelerim/venv/bin/python /home/azamet/Belgeler/projelerim/remover.py
Traceback (most recent call last):
  File "/home/azamet/Belgeler/projelerim/remover.py", line 20, in <module>
    job = client.createTask(task)
  File "/home/azamet/.local/lib/python3.8/site-packages/python_anticaptcha/base.py", line 128, in createTask
    self._check_response(response)
  File "/home/azamet/.local/lib/python3.8/site-packages/python_anticaptcha/base.py", line 112, in _check_response
    raise AnticaptchaException(
python_anticaptcha.exceptions.AnticaptchaException: [ERROR_KEY_DOES_NOT_EXIST:1]Account authorization key not found in the system

Process finished with exit code 1

after running the code at top the token is removed from stored tokens but i everytime get this error what am i doing wrong here? and thanks again for this library

NoahCardoza commented 4 years ago

Maybe because you are passing a captcha token to the AnticaptchaClient?

image

Not to mention that after you grab the token you have the browser wait for at least 1 minute via driver.implicitly_wait(30) and wait = WebDriverWait(driver, 30).