超级鹰的使用

利用超级鹰验证验证码

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代码
相关推荐
小白学大数据1 天前
百科词条结构化抓取:Java 正则表达式与 XPath 解析对比
java·开发语言·爬虫·正则表达式
泡泡以安1 天前
【爬虫教程】第4章:HTTP客户端库深度定制(httpx/aiohttp)
爬虫·http·httpx
熊文豪1 天前
Selenium 自动化测试入门指南
selenium·测试工具
唐古乌梁海1 天前
Selenium元素定位不稳定
python·selenium·测试工具
@杨某1 天前
selenium嵌入scrapy动态网页抓取
selenium·测试工具·scrapy
搞全栈小苏1 天前
【Python 爬虫实战】一键批量下载 Python 官网 FTP 所有版本全部文件(多线程 + 断点续传 + 禁用系统代理 完整版)
开发语言·爬虫·python
泡泡以安1 天前
【爬虫教程】第5章:WebSocket协议解析与长连接管理
爬虫·websocket·网络协议
laocooon5238578861 天前
《网络爬虫实战:小说内容抓取》教案
爬虫
亿牛云爬虫专家2 天前
Worker越简单,系统越稳定:从单机到集群
爬虫·python·集群·爬虫代理·单机·代理ip·worker