def callback(resp): path = self.checkimg_path fp = open(path, 'wb') fp.write(resp.body) fp.close() if UPLOAD_CHECKIMG: logging.info(u"正在上传验证码..") res = upload_file("check.jpg", path) path = res.read() check_code = "" if not HTTP_CHECKIMG: print u"验证图片: {0}".format(path) while not check_code: check_code = raw_input("输入验证图片上的验证码: ") ccode = check_code.strip().lower() self.check_code = ccode pwd = self.handle_pwd(r, ccode.upper(), uin) self.before_login(pwd) else: if os.path.exists("wait"): os.remove("wait") logging.info(u"请打开http://{0}:{1} 提交验证码" .format(HTTP_LISTEN, HTTP_PORT)) self.handler.r = r self.handler.uin = uin self.handler.next_callback = self.before_login self.require_check_time = time.time() if EMAIL_NOTICE: if send_notice_email(): logging.info(u"已成功发送邮件提醒") else: logging.warn(u"发送邮件提醒失败")
def callback(resp): path = self.checkimg_path fp = open(path, "wb") fp.write(resp.body) fp.close() if UPLOAD_CHECKIMG: logging.info(u"正在上传验证码..") res = upload_file("check.jpg", path) path = res.read() check_code = "" if not HTTP_CHECKIMG: print u"验证图片: {0}".format(path) while not check_code: check_code = raw_input("输入验证图片上的验证码: ") ccode = check_code.strip().lower() self.check_code = ccode pwd = self.handle_pwd(r, ccode.upper(), uin) self.before_login(pwd) else: if os.path.exists("wait"): os.remove("wait") logging.info(u"请打开http://{0}:{1} 提交验证码".format(HTTP_LISTEN, HTTP_PORT)) self.handler.r = r self.handler.uin = uin self.handler.next_callback = self.before_login self.require_check_time = time.time() if EMAIL_NOTICE: if send_notice_email(): logging.info(u"已成功发送邮件提醒") else: logging.warn(u"发送邮件提醒失败")
def callback(resp): path = os.path.join(os.path.abspath(os.path.dirname(__file__)), "check.jpg") fp = open(path, 'wb') fp.write(resp.body) fp.close() if UPLOAD_CHECKIMG: res = upload_file("check.jpg", path) path = res.url print u"验证图片: {0}".format(path) check_code = "" while not check_code: check_code = raw_input("输入验证图片上的验证码: ") ccode = check_code.strip().lower() self.check_code = ccode pwd = self.handle_pwd(r, ccode.upper(), uin) self.before_login(pwd)
def get_check_img(self, vcode): """ 获取验证图片 """ url = "https://ssl.captcha.qq.com/getimage" params = [("aid", self.aid), ("r", random.random()), ("uin", self.qid)] request = self.http_stream.make_get_request(url, params) cookie = urllib2.HTTPCookieProcessor(self.http_stream.cookiejar) opener = urllib2.build_opener(cookie) res = opener.open(request) path = os.path.join(os.path.abspath(os.path.dirname(__file__)), "check.jpg") fp = open(path, 'wb') fp.write(res.read()) fp.close() if UPLOAD_CHECKIMG: res = upload_file("check.jpg", path) path = res.url print u"验证图片: {0}".format(path) check_code = "" while not check_code: check_code = raw_input("输入验证图片上的验证码: ") return check_code.strip().upper()