python - AttributeError:“TwoCaptcha”对象没有属性“recaptcha”
问题描述
我尝试解决绕过验证码但不工作。
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
推荐阅读
- angular - Angular 7 调用 Azure Indexer 服务
- javascript - 使用 jscolor 选择器更改 div 径向渐变颜色
- php - 如何修复 wp-config.php 以在 WordPress 中上传图片?
- spring-boot - Minikube springboot 收到请求并没有正确响应
- javascript - 切换选项卡时 Flickity 不会初始化
- qt - 如何为 QLineEdit 添加 2 个自定义按钮?
- scala - 将 RDD 放在可序列化的类中是不是很糟糕?
- c# - 在 Azure 上部署 Telegram 机器人
- properties - 如何在自动运行 SOAP UI 测试中使用来自外部文件的属性?
- spring-boot - 拦截请求并发送到外部