超级鹰的使用

利用超级鹰验证验证码

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代码
相关推荐
喵手8 小时前
Python爬虫零基础入门【第九章:实战项目教学·第15节】搜索页采集:关键词队列 + 结果去重 + 反爬友好策略!
爬虫·python·爬虫实战·python爬虫工程化实战·零基础python爬虫教学·搜索页采集·关键词队列
喵手9 小时前
Python爬虫零基础入门【第九章:实战项目教学·第14节】表格型页面采集:多列、多行、跨页(通用表格解析)!
爬虫·python·python爬虫实战·python爬虫工程化实战·python爬虫零基础入门·表格型页面采集·通用表格解析
0思必得09 小时前
[Web自动化] 爬虫之API请求
前端·爬虫·python·selenium·自动化
喵手9 小时前
Python爬虫实战:从零构建 Hacker News 数据采集系统:API vs 爬虫的技术抉择!(附CSV导出 + SQLite 存储)!
爬虫·python·爬虫实战·hacker news·python爬虫工程化实战·零基础python爬虫教学·csv导出
0思必得011 小时前
[Web自动化] 爬虫之网络请求
前端·爬虫·python·selenium·自动化·web自动化
喵手11 小时前
Python爬虫零基础入门【第九章:实战项目教学·第6节】断点续爬:任务状态表 + 失败队列重放!
爬虫·python·爬虫实战·python爬虫工程化实战·零基础python爬虫教学·断点续爬·任务状态表
安然无虞13 小时前
「深入理解多线程编程」再谈线程
爬虫·python·测试工具
小尘要自信14 小时前
高级网络爬虫实战:动态渲染、反爬对抗与分布式架构
分布式·爬虫·架构
深蓝电商API14 小时前
Selenium 与 BeautifulSoup 结合解析页面
爬虫·python·selenium·beautifulsoup
深蓝电商API16 小时前
Selenium 绕过 Cloudflare 反爬检测
爬虫·python·selenium