当前位置:网站首页 > 技术博客 > 正文

python随机生成验证码



#!/usr/bin/env python # coding:utf-8 import requests from hashlib import md5 class RClient(object): def __init__(self, username='shaoks123', password='', soft_id='', soft_key='c0d07d796c8e470c92a126df60d61794'): self.username = username # self.password = md5(password).hexdigest() self.password = md5(password.encode("utf-8")).hexdigest() self.soft_id = soft_id self.soft_key = soft_key self.base_params = { 'username': self.username, 'password': self.password, 'softid': self.soft_id, 'softkey': self.soft_key, } self.headers = { 'Connection': 'Keep-Alive', 'Expect': '100-continue', 'User-Agent': 'ben', } def rk_create(self, im, im_type, timeout=60): """ im: 图片字节 im_type: 题目类型 """ params = { 'typeid': im_type, 'timeout': timeout, } params.update(self.base_params) files = {'image': ('a.jpg', im)} r = requests.post('http://api.ruokuai.com/create.json', data=params, files=files, headers=self.headers) return r.json() def rk_report_error(self, im_id): """ im_id:报错题目的ID """ params = { 'id': im_id, } params.update(self.base_params) r = requests.post('http://api.ruokuai.com/reporterror.json', data=params, headers=self.headers) return r.json() def test(self,imagefile,im_type=1030): # im = open('E:python36_crawlVeriycodecodecode_823.png', 'rb').read() im = open(imagefile, 'rb').read() result = self.rk_create(im, im_type) print(result['Result']) return result['Result'] # if __name__ == '__main__': # rc = RClient() # im = open('E:python36_crawlVeriycodecodecode_823.png', 'rb').read() # result = rc.rk_create(im, 1030) # print(result['Result'])

版权声明


相关文章:

  • 实验室服务器配置2025-05-31 08:01:05
  • 灰度发布实现手段2025-05-31 08:01:05
  • 如何打开全局代理2025-05-31 08:01:05
  • 二阶有源带通滤波器的设计2025-05-31 08:01:05
  • sql触发器的使用及语法2025-05-31 08:01:05
  • java笔试题大全带答案2025-05-31 08:01:05
  • 三态门的定义和功能2025-05-31 08:01:05
  • microsoft visual c++2010安装2025-05-31 08:01:05
  • ce认证公告机构查询2025-05-31 08:01:05
  • java虚拟机详解2025-05-31 08:01:05