关于selenium登陆某些页面或者系统都会遇到验证码
获取验证码 并自动填写 就是使用selenium自动登陆的关键
首先关于识别图片中的验证码有以下步骤
1,获取验证码图片
2,使用某些识别软件识别图中验证码的信息
3,返回获取的验证码,并填写
关于识别验证码文件,我选择云打码http://www.yundama.com/about.html
登陆注册并花费1元购买使用权
注册开发者进入我的软件
如图点击添加新软件,获取其中的软件代码及通讯秘钥保存下来
下载pythonhttp调试获取其中的
并把它放入你要使用的文件夹内,该代码内容如下
import http.client, mimetypes, urllib, json, time, requests
######################################################################
class YDMHttp:
apiurl = 'http://api.yundama.com/api.php'
username = ''
password = ''
appid = ''
appkey = ''
def __init__(self, username, password, appid, appkey):
self.username = username
self.password = password
self.appid = str(appid)
self.appkey = appkey
def request(self, fields, files=[]):
response = self.post_url(self.apiurl, fields, files)
response = json.loads(response)
return response
def balance(self):
data = {'method': 'balance', 'username': self.username, 'password': self.password, 'appid': self.appid, 'appkey': self.appkey}
response = self.request(data)
if (response):
if (response['