超级鹰的使用

利用超级鹰验证验证码

python 复制代码
from selenium import webdriver
from chaojiying import Chaojiying_Client

browser = webdriver.Chrome()
browser.get("")
username = browser.find_element(By.XPATH,"")
username.send_keys("")
password = browser.find_element(By.XPATH,"")
password.send_keys("")
img = browser.find_element().screenshot_as_png
chaojiying = Chaojiying_Client("username","password","soft_id")#用户中心>>软件ID 生成一个替换 96001
dic = chaojiying.postPic(img,1902)
verify_code = dic["pic_str"]#获取验证码
browser.find_element("").send_keys(verify_code)
browser.find_element("").click()
cookie_dict = browser.get_cookies()
print(cookie_dict)
browser.quit()

#使用cookie免密码登录网页

python 复制代码
browser = webdriver.Chrome()
browser.get("")
browser.implicitly_wait(10)
cookies = [{}]
for cookie in cookies
	if 'expiry' in cookie:
		del cookie['expiry']
	browser.add_cookie(cookie)
browser.refresh()
browser.get("")
  • 超级鹰代码
python 复制代码
#!/usr/bin/env python
# coding:utf-8

import requests
from hashlib import md5

class Chaojiying_Client(object):

    def __init__(self, username, password, soft_id):
        self.username = username
        password =  password.encode('utf8')
        self.password = md5(password).hexdigest()
        self.soft_id = soft_id
        self.base_params = {
            'user': self.username,
            'pass2': self.password,
            'softid': self.soft_id,
        }
        self.headers = {
            'Connection': 'Keep-Alive',
            'User-Agent': 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)',
        }

    def PostPic(self, im, codetype):
        """
        im: 图片字节
        codetype: 题目类型 参考 http://www.chaojiying.com/price.html
        """
        params = {
            'codetype': codetype,
        }
        params.update(self.base_params)
        files = {'userfile': ('ccc.jpg', im)}
        r = requests.post('http://upload.chaojiying.net/Upload/Processing.php', data=params, files=files, headers=self.headers)
        return r.json()

    def PostPic_base64(self, base64_str, codetype):
        """
        im: 图片字节
        codetype: 题目类型 参考 http://www.chaojiying.com/price.html
        """
        params = {
            'codetype': codetype,
            'file_base64':base64_str
        }
        params.update(self.base_params)
        r = requests.post('http://upload.chaojiying.net/Upload/Processing.php', data=params, headers=self.headers)
        return r.json()

    def ReportError(self, im_id):
        """
        im_id:报错题目的图片ID
        """
        params = {
            'id': im_id,
        }
        params.update(self.base_params)
        r = requests.post('http://upload.chaojiying.net/Upload/ReportError.php', data=params, headers=self.headers)
        return r.json()


if __name__ == '__main__':
    chaojiying = Chaojiying_Client('yz572204188', 'mima', '96001')	#用户中心>>软件ID 生成一个替换 96001
    im = open('a.jpg', 'rb').read()													#本地图片文件路径 来替换 a.jpg 有时WIN系统须要//
    print(chaojiying.PostPic(im, 1902))											#1902 验证码类型  官方网站>>价格体系 3.4+版 print 后要加()
    #print chaojiying.PostPic(base64_str, 1902)  #此处为传入 base64代码
相关推荐
_.Switch7 小时前
东方财富股票数据JS逆向:secids字段和AES加密实战
开发语言·前端·javascript·网络·爬虫·python·ecmascript
码界奇点10 小时前
基于Python的新浪微博数据爬虫系统设计与实现
数据库·爬虫·python·毕业设计·新浪微博·源代码管理
tang7778914 小时前
代理IP质量检测实战:Python实现IP可用性、延迟、匿名度自动测试脚本
大数据·爬虫·python·网络协议·tcp/ip
datascome2 天前
文章自动采集发布到Discuz网站技巧
经验分享·爬虫·数据采集·discuz·网站内容批量发布
亿牛云爬虫专家2 天前
Go爬虫进阶:如何优雅地在Colly框架中实现无缝代理切换?
爬虫·中间件·golang·爬虫代理·colly框架·代理切换·api提取
小白学大数据2 天前
Python 3.7 高并发爬虫:接口请求与页面解析并发处理
开发语言·爬虫·python
深蓝电商API3 天前
淘宝商品主图视频下载:从 API 返回值中提取视频 URL 并转码
爬虫·接口·api·淘宝api
测试19983 天前
Selenium自动化测试框架的搭建
自动化测试·软件测试·python·selenium·测试工具·职场和发展·测试用例