我正在尝试使用Selenium在网站上自动化登录过程。我想输入我的数据,然后自己输入验证码。但是,当我单击验证码时,我会收到大量的验证码和错误。有什么方法可以让我不遇到恒定的验证码吗?
验证码是专门为破坏自动化而设计的。我会要求产品负责人添加某种 cookie 或机制,以使 chaptcha 不存在。
不幸的是,正如@Dominic所说,验证码无法破解。但是我已经要求开发人员为测试环境包含URL参数,该参数可以在测试环境中用于禁用/隐藏CAPTCH-as。但是,如果您想调查,我听说过这项服务 http://deathbycaptcha.com 当然必须付费。
以下是一些补充代码:
import com.DeathByCaptcha.AccessDeniedException;
import com.DeathByCaptcha.Captcha;
import com.DeathByCaptcha.Client;
import com.DeathByCaptcha.SocketClient;
import com.DeathByCaptcha.HttpClient;
/* Put your DeathByCaptcha account username and password here.
Use HttpClient for HTTP API. */
Client client = (Client)new SocketClient(username, password);
try {
double balance = client.getBalance();
/* Put your CAPTCHA file name, or file object, or arbitrary input stream,
or an array of bytes, and optional solving timeout (in seconds) here: */
Captcha captcha = client.decode(captchaFileName, timeout);
if (null != captcha) {
/* The CAPTCHA was solved; captcha.id property holds its numeric ID,
and captcha.text holds its text. */
System.out.println("CAPTCHA " + captcha.id + " solved: " + captcha.text);
if (/* check if the CAPTCHA was incorrectly solved */) {
client.report(captcha);
}
}
} catch (AccessDeniedException e) {
/* Access to DBC API denied, check your credentials and/or balance */
}
这段代码没有经过测试,我刚刚在网上找到,也许它会帮助你。