超级鹰的使用

利用超级鹰验证验证码

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代码
相关推荐
数据知道20 小时前
斩断 `navigator` 前端:底层重写 UserAgent/Platform/Language 属性描述符
爬虫·数据采集·指纹浏览器·浏览器指纹
深蓝电商API1 天前
Playwright深入浅出:从入门到企业级项目实战
爬虫·playwright
小白学大数据1 天前
爬虫性能天花板:asyncio赋能 Aiohttp,并发提速 10 倍
开发语言·爬虫·数据分析
yijianace1 天前
Python爬虫实战:分页爬取 + 详情页采集 + CSV存储
前端·爬虫·python
yijianace1 天前
Python爬虫实战:ThreadPoolExecutor多线程采集书籍信息与图片下载
开发语言·爬虫·python
在放️1 天前
Python 爬虫 · bs4 模块基础
开发语言·爬虫·python
belong_my_offer1 天前
Python 数据采集完全指南 —— 从零开始掌握网络爬虫与文件读取
开发语言·爬虫·python
深蓝电商API1 天前
Playwright vs Puppeteer vs Selenium 2026终极对比
爬虫·selenium·puppeteer·playwright
遇事不決洛必達2 天前
【Python基础】GIL 锁是什么及其对爬虫的影响
爬虫·python·线程·进程·gil锁
綝~2 天前
爬虫数据采集工程师岗位面试题
爬虫·面试·请求