예제 #1
0
def get_comicbook_from_cache(site, comicid=None):
    comicbook = ComicBook(site=site, comicid=comicid)
    proxy_config = current_app.config.get(ConfigKey.CRAWLER_PROXY, {})
    proxy = proxy_config.get(site)
    if proxy:
        SessionMgr.set_proxy(site=site, proxy=proxy)
    cookies_path = get_cookies_path(site=site)
    if os.path.exists(cookies_path):
        SessionMgr.load_cookies(site=site, path=cookies_path)
    return comicbook
예제 #2
0
def init_session(app):
    with app.app_context():
        proxy_config = app.config.get(ConfigKey.CRAWLER_PROXY, {})
        for site in ComicBook.CRAWLER_CLS_MAP:
            proxy = proxy_config.get(site)
            if proxy:
                SessionMgr.set_proxy(site=site, proxy=proxy)
            cookies_path = get_cookies_path(site=site)
            if os.path.exists(cookies_path):
                SessionMgr.load_cookies(site=site, path=cookies_path)
예제 #3
0
def init_session(app):
    CrawlerBase.DRIVER_PATH = app.config.get('DRIVER_PATH', '')
    CrawlerBase.DRIVER_TYPE = app.config.get('DRIVER_TYPE', '')
    CrawlerBase.HEADLESS = True
    with app.app_context():
        proxy_config = app.config.get(ConfigKey.CRAWLER_PROXY, {})
        for site in ComicBook.CRAWLER_CLS_MAP:
            proxy = proxy_config.get(site)
            if proxy:
                SessionMgr.set_proxy(site=site, proxy=proxy)
            cookies_path = get_cookies_path(site=site)
            if os.path.exists(cookies_path):
                SessionMgr.load_cookies(site=site, path=cookies_path)