Improve behaviour without cfscrape
This commit is contained in:
parent
0d7bb6fdf6
commit
553f6fe7d4
|
@ -150,13 +150,17 @@ STANDARD_HEADERS = {
|
|||
}
|
||||
|
||||
|
||||
class CachedCfScrape(requests_cache.CacheMixin, cfscrape.CloudflareScraper):
|
||||
pass
|
||||
if cfscrape:
|
||||
class CachedCfScrape(requests_cache.CacheMixin, cfscrape.CloudflareScraper):
|
||||
pass
|
||||
|
||||
|
||||
def get_session(cookiejar, *, with_cfscrape: bool) -> requests.Session:
|
||||
assert isinstance(with_cfscrape, bool)
|
||||
session = CachedCfScrape('web_cache', cookies=cookiejar)
|
||||
session_class = requests_cache.CachedSession
|
||||
if cfscrape:
|
||||
session_class = CachedCfScrape
|
||||
session = session_class('web_cache', cookies=cookiejar)
|
||||
for cookie in cookiejar:
|
||||
session.cookies.set_cookie(cookie)
|
||||
return session
|
||||
|
|
Loading…
Reference in New Issue
Block a user