mirror of
https://github.com/Suxiaoqinx/Netease_url.git
synced 2025-07-13 12:52:22 +08:00
Add files via upload
This commit is contained in:
parent
134543d59f
commit
19f745edbb
19
cookie_manager.py
Normal file
19
cookie_manager.py
Normal file
@ -0,0 +1,19 @@
|
||||
import os
|
||||
from typing import Dict
|
||||
|
||||
class CookieManager:
|
||||
def __init__(self, cookie_file: str = None):
|
||||
if cookie_file is None:
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
cookie_file = os.path.join(script_dir, 'cookie.txt')
|
||||
self.cookie_file = cookie_file
|
||||
|
||||
def read_cookie(self) -> str:
|
||||
with open(self.cookie_file, 'r', encoding='utf-8') as f:
|
||||
return f.read()
|
||||
|
||||
@staticmethod
|
||||
def parse_cookie(text: str) -> Dict[str, str]:
|
||||
cookie_ = [item.strip().split('=', 1) for item in text.strip().split(';') if item]
|
||||
cookie_ = {k.strip(): v.strip() for k, v in cookie_}
|
||||
return cookie_
|
Loading…
Reference in New Issue
Block a user