cqwu-ehall/cqwu/methods/auth/export_cookie_to_file.py

18 lines
431 B
Python
Raw Normal View History

2022-08-10 15:12:43 +00:00
import cqwu
from cqwu.errors.auth import CookieError
class ExportCookieToFile:
async def export_cookie_to_file(
self: "cqwu.Client",
):
"""
导出 cookie 到文件
"""
if not self.cookies:
raise CookieError()
data = "".join(f"{key}={value};" for key, value in self.cookies.items())
with open(self.cookie_file_path, "w") as f:
f.write(data)