找回密码
 立即注册
搜索
热搜: Excel discuz
查看: 1142|回复: 0

[项目代码] 超级鹰识别古诗文网验证码

[复制链接]

482

主题

7万

元宝

75万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
750848
发表于 2021-8-12 21:47:44 | 显示全部楼层 |阅读模式
  1. import requests
  2. from lxml import etree
  3. from hashlib import md5
  4. class Chaojiying_Client(object):

  5.     def __init__(self, username, password, soft_id):
  6.         self.username = username
  7.         password =  password.encode('utf8')
  8.         self.password = md5(password).hexdigest()
  9.         self.soft_id = soft_id
  10.         self.base_params = {
  11.             'user': self.username,
  12.             'pass2': self.password,
  13.             'softid': self.soft_id,
  14.         }
  15.         self.headers = {
  16.             'Connection': 'Keep-Alive',
  17.             'User-Agent': 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)',
  18.         }

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

  31.     def ReportError(self, im_id):
  32.         """
  33.         im_id:报错题目的图片ID
  34.         """
  35.         params = {
  36.             'id': im_id,
  37.         }
  38.         params.update(self.base_params)
  39.         r = requests.post('http://upload.chaojiying.net/Upload/ReportError.php', data=params, headers=self.headers)
  40.         return r.json()
  41. url = 'https://so.gushiwen.cn/user/login.aspx?from=http://so.gushiwen.cn/user/collect.aspx'
  42. UA = {'user-agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'}
  43. respon = requests.get( url = url,headers=UA).text
  44. jiexi = etree.HTML(respon)
  45. tupian = 'https://so.gushiwen.cn' + jiexi.xpath('//*[@id="imgCode"]/@src')[0]
  46. respon = respon = requests.get( url = tupian,headers=UA).content
  47. with open('c:/c/1.jpg','wb') as a:
  48.     a.write(respon)
  49. chaojiying = Chaojiying_Client('qianzhou', 'qianzhou', '921008')        #用户中心>>软件ID 生成一个替换 96001
  50. im = open('c:/c/1.jpg', 'rb').read()                                                                                                        #本地图片文件路径 来替换 a.jpg 有时WIN系统须要//
  51. 验证码 = chaojiying.PostPic(im, 1902)['pic_str']
  52. print(chaojiying.PostPic(im, 1902)['pic_str'])
复制代码



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|五花八门论坛 ( 豫ICP备15031300号-3 )

GMT+8, 2024-4-24 09:04 , Processed in 0.094472 second(s), 27 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表