mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-13 14:44:29 -04:00
Fix cookies being set incorrectly
This commit is contained in:
parent
68326a60ee
commit
4686da91e6
1 changed files with 11 additions and 11 deletions
|
@ -172,19 +172,19 @@ def download_url(url: str, timeout: int=None) -> str:
|
||||||
COOKIES_FILE,
|
COOKIES_FILE,
|
||||||
)
|
)
|
||||||
timeout = timeout or TIMEOUT
|
timeout = timeout or TIMEOUT
|
||||||
|
session = requests.Session()
|
||||||
|
|
||||||
cookie_jar = http.cookiejar.MozillaCookieJar()
|
if COOKIES_FILE and Path(COOKIES_FILE).is_file():
|
||||||
if COOKIES_FILE is not None:
|
cookie_jar = http.cookiejar.MozillaCookieJar(COOKIES_FILE)
|
||||||
cookie_jar.load(COOKIES_FILE, ignore_discard=True, ignore_expires=True)
|
cookie_jar.load(ignore_discard=True, ignore_expires=True)
|
||||||
else:
|
for cookie in cookie_jar:
|
||||||
cookie_jar = None
|
session.cookies.set(cookie.name, cookie.value, domain=cookie.domain, path=cookie.path)
|
||||||
|
|
||||||
response = requests.get(
|
response = session.get(
|
||||||
url,
|
url,
|
||||||
headers={'User-Agent': WGET_USER_AGENT},
|
headers={'User-Agent': WGET_USER_AGENT},
|
||||||
verify=CHECK_SSL_VALIDITY,
|
verify=CHECK_SSL_VALIDITY,
|
||||||
timeout=timeout,
|
timeout=timeout,
|
||||||
cookies=cookie_jar,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
content_type = response.headers.get('Content-Type', '')
|
content_type = response.headers.get('Content-Type', '')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue