python - 属性错误 : 'TwoCaptcha' object has no attribute 'recaptcha'

标签 python

我尝试解决绕过验证码但不起作用。

  
import requests
import bs4
from twocaptcha import TwoCaptcha
import os

TwoCaptcha_api_key = ""
renew_url = ""
renew_session = requests.session()
renew_request = renew_session.get(renew_url)
renew_content = renew_request._content
renew_soup = bs4.BeautifulSoup(renew_content, 'lxml')

renew_sitekey = renew_soup.find('div', {"class":"g-recaptcha"})['data-sitekey']

renew_token = renew_soup.find('input', {"name":"_token"})['value']
solve = TwoCaptcha(TwoCaptcha_api_key)
result = solve.recaptcha(
    sitekey=renew_sitekey,
    url=renew_url)

recaptcha_response = result['code']
postdata = {"username": "AAAAAAA", "g-recaptcha-response": f"{recaptcha_response}", "_token": f"{renew_token}" }
renew_post = renew_session.post(renew_url, data=postdata)
print(renew_post)
我得到了这个错误
Traceback (most recent call last):<br>
  File "", line 18, in <module><br>
    result = solve.recaptcha(<br>
AttributeError: 'TwoCaptcha' object has no attribute 'recaptcha'

最佳答案

我猜你在谈论这个包裹 https://pypi.org/project/2captcha-python/#solve-captcha解决验证码。
我也在猜测,你一定是用了一些 IDE 来安装这个安装错误的包。 ( https://pypi.org/project/TwoCaptcha/ ) 这是原始包装的包装。
删除当前不正确的包 pip uninstall TwoCaptcha并安装正确的 pip install 2captcha-python

关于python - 属性错误 : 'TwoCaptcha' object has no attribute 'recaptcha' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66622115/

相关文章:

python - 如何在 Python 中唯一标识媒体文件的内容,而不是元数据?

python - 使用 haystack 和 Whoosh

Python Ctypes 键盘事件

python - 通过 SQLAlchemy 在 MySQL 数据库中写入 Pandas Dataframe

python - 从两个列表创建字典?在取平均值时?

python - Tensorflow:无法将 tf.case 与输入参数一起使用

python curl 执行带参数的命令

python - 将 ord() 与 ascii 选项卡、输入等一起使用

Python:将 numpy 数组保存到 ROOT 文件

python - 是否可以将 django 模型类与 ManyToMany 关系合并?