会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 134103个问题

#!/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 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()

def get_code(filename,code_type=1902):
    chaojiying = Chaojiying_Client('dearzyq', '123456', '906030')  # 用户中心>>软件ID 生成一个替换 96001
    im = open(filename, 'rb').read()  # 本地图片文件路径 来替换 a.jpg 有时WIN系统须要//
    resp = chaojiying.PostPic(im,code_type)   # 1902 验证码类型  官方网站>>价格体系 3.4+版 print 后要加()
    return resp.get('pic_str')

if __name__ == '__main__':
    print(get_code('a.jpg'))
    
   #图片识别不出来


Python全系列/第十六阶段:Python 爬虫开发/爬虫反反爬- 31906楼
JAVA 全系列/第八阶段:Linux入门到实战/Git 31912楼

分享,减少踩坑!

我直接使用pip install mysqlclient报了 MySQLdb/_mysql.c(29): fatal error C1083: 无法打开包括文件: “mysql.h”: No such file or directory

image.png

在卸载了Visual Studio Community 2019后,再次使用pip install mysqlclient,报了error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/

image.png

这会引导去安装好几个G的visual studio ,但是可以不用去安装这个占存储空间的工具,直接在https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient 中下载与当前安装的python版本兼容的mysqlclient,

image.png

比如我当前用的python 3.8.3版本是32位的,则应下载mysqlclient-1.4.6-cp38-cp38-win32.whl

下载好后进入该文件所在的目录,命令行输入pip install mysqlclient-1.4.6-cp38-cp38-win32.whl

显示安装成功

image.png

注意:如果安装的mysqlclient版本与当前Python版本不兼容,则会报ERROR: mysqlclient-1.4.6-cp38-cp38-win_amd64.whl is not a supported wheel on this platform.

image.png

Python全系列/第十二阶段:Python_Django3框架/Django初级 31916楼
JAVA 全系列/第一阶段:AI驱动的JAVA编程/IDEA的使用和第一个java项目 31920楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637