Beispiel #1
0
        def prepare():
            req = Request(urljoin(cv.REPO, 'repo'), headers=HEADERS)
            res = urlopen(req)
            text = raw_decompress(res.read(), res.info())
            parser_info = eval(text)

            for i, j in list(parser_info.items()):
                if os.path.exists(os.path.join(cv.PARSER_PATH, i)):
                    with open(os.path.join(cv.PARSER_PATH, i), 'rb') as f:
                        _md5 = md5()
                        _md5.update(f.read())
                        if _md5.hexdigest() == j:
                            del parser_info[i]

            return parser_info
Beispiel #2
0
    def auth_refresh(self):
        add_params = logintoken_auth_refresh.copy()
        add_params['_'] = str(int(time.time() * 1000))
        add_params['type'] = self.user.main_login

        new_url = make_query(AUTH_REFRESH_URL, add_params)

        res = self.requestRaw(url=new_url)
        raw = res.read()
        text = raw_decompress(raw, res.info())

        res.close()
        res_josn = json.loads(text[text.index('{'):])

        if res_josn['errcode'] != 0:
            raise Exception('导入的cookie不正确,返回:', res_josn['msg'])

        self.user.extract_headers(res.info().get_all('set-cookie'))
        new_cookie_str = self.user.dumps()
        self.saveCookie(new_cookie_str)
        self.loadCookie(new_cookie_str)
        return True