def save(self, *args, **kwargs): if self.worse_md5 in (None, u''): self.worse_md5 = md5_digest(self.worse_url) if self.better_md5 in (None, u''): self.better_md5 = md5_digest(self.better_url) super(Edge, self).save(*args, **kwargs)
def post(head, url, data, raw=False): timestamp = str(int(datetime.now().timestamp() * 1000)) s.headers.update({'Timestamp': timestamp}) if head == SIGN: s.headers.update( {'App-Signature': utils.md5_digest(app_key + timestamp + secret)}) elif head == TICKET: s.headers.update({'App-Ticket': ticket}) r = s.post(SERVER + url, data=data, verify=SSL_VERIFY) if raw is True: return r.text return r.json()['rt']
with open('userinfo.py', 'w+', encoding='utf-8') as f: f.writelines(f'USER = {u}\n') f.writelines(f'NAME = "{n}"\n') f.writelines(f'SECRET = "{se}"') logger.info('Login OK.') return u, n, se if __name__ == '__main__': logging.basicConfig(format='%(asctime)s %(levelname)-8s %(message)s', level=logging.INFO) logger = logging.getLogger() logger.info('I love studying! Study makes me happy!') rsa_key = RSA.import_key(open('key.pem', 'r').read()) app_key = utils.md5_digest(str(uuid.uuid4()).replace('-', '')) s = requests.Session() s.headers.update({ 'User-Agent': 'Dalvik/2.1.0 (Linux; U; Android 7.1.1; Nexus 5X Build/NOF27B', 'Accept-Encoding': 'gzip', 'App-Key': app_key }) secret = '' ticket = '' try: import userinfo user = userinfo.USER