示例#1
0
文件: base.py 项目: QQiot/AMZ_EMAIL
class MyDecapcha:
    def __init__(self):
        self.user = '******'
        self.passwd = 'AAbb1122'
        self.client = SocketClient(self.user, self.passwd)
        self.client.is_verbose = False

    def __enter__(self):
        return self

    def __exit__(self, exc_type, exc_value, traceback):
        try:
            self.client.close()
        except Exception:
            log.exception('Failed to close dbc client')

    def decode(self, fn, timeout=60):
        try:
            captcha = self.client.decode(fn, timeout=timeout)
            return captcha['text'].strip()
        except Exception:
            log.exception('Failed to decode')
            return None