def login(captchaKey): captcha = input('captcha:') params = urllib.parse.urlencode({'captcha': captcha, 'password': '******', 'account': 'zephyrzoom', 'captchaKey': captchaKey}) mylog.writeLog('post', ZHANQI_URL + LOGIN_URL + '?' + params) urllib.request.install_opener(opener) with urllib.request.urlopen(ZHANQI_URL + LOGIN_URL + '?' + params) as f: loginInfo = f.read().decode('utf-8') mylog.writeLog('login', loginInfo)
def getCaptcha(): with urllib.request.urlopen(ZHANQI_URL + CAPTCHA_URL) as f: captchaJson = f.read().decode('utf-8') mylog.writeLog('get', captchaJson) captchaDict = json.loads(captchaJson) #mylog.writeLog('info', captchaDict) captchaImg = captchaDict['data']['img'] captchaKey = captchaDict['data']['captchaKey'] mylog.writeLog('img', captchaImg) print(captchaImg) return captchaKey