RSADemo.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:MyPython 作者: fupinglee 项目源码 文件源码
def readCaptcha(self):#?????


        headers = {
            'Accept-Language':'zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3',
            'User-Agent':'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0',
            'Referer':'http://******/login.jsp',
            'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8',
            'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
            'X-Forwarded-For':self.captchaId
        }           
        url = 'http://******/common/captcha.jhtml?captchaId='+self.captchaId
        try:    
            res = requests.get(url,headers=headers)  
        except requests.exceptions.ConnectionError:
            print '??????'

        path = "i:/img/"+self.captchaId+".png"
        fp = open(path,'wb')
        fp.write(res.content)
        fp.close()
        image = Image.open(path)
        code = pytesseract.image_to_string(image)
        self.captcha = code
        #print code
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号