Esempio n. 1
0
def cloudflare_get(url, cookies={}, proxies=None):
    retry = 6
    from JavHelper.core.javlibrary import JavLibraryScraper
    while retry > 0:
        try:
            cookies.update(JavLibraryScraper.load_local_cookies()
                           )  # update cloudflare cookies when updating
            res = cloudscraper.create_scraper().get(url,
                                                    cookies=cookies,
                                                    proxies=proxies)
            #print(res.text)
            return res
        #except cloudscraper.exceptions.CloudflareIUAMError:
        except Exception as e:
            print(f'cloudflare get failed on {e}, retrying {url}')
            retry = retry - 1
            sleep(5)

    raise Exception(f'cloudflare get {url} failed')
Esempio n. 2
0
def read_javlib_cf_cookies():
    return jsonify({
        'javlib_cf_cookies':
        JavLibraryScraper.load_local_cookies(
            return_all=request.args.get('return_all', False))
    })  # convert returned obj to dict format