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
评论列表
文章目录