Merge pull request #139 from andaoai/fix/cookies-directory-not-found
fix: 保存cookie前创建cookiesFile目录以防止文件不存在错误
This commit is contained in:
+16
-4
@@ -50,7 +50,10 @@ async def douyin_cookie_gen(id,status_queue):
|
||||
return None
|
||||
uuid_v1 = uuid.uuid1()
|
||||
print(f"UUID v1: {uuid_v1}")
|
||||
await context.storage_state(path=Path(BASE_DIR / "cookiesFile" / f"{uuid_v1}.json"))
|
||||
# 确保cookiesFile目录存在
|
||||
cookies_dir = Path(BASE_DIR / "cookiesFile")
|
||||
cookies_dir.mkdir(exist_ok=True)
|
||||
await context.storage_state(path=cookies_dir / f"{uuid_v1}.json")
|
||||
result = await check_cookie(3, f"{uuid_v1}.json")
|
||||
if not result:
|
||||
status_queue.put("500")
|
||||
@@ -125,7 +128,10 @@ async def get_tencent_cookie(id,status_queue):
|
||||
return None
|
||||
uuid_v1 = uuid.uuid1()
|
||||
print(f"UUID v1: {uuid_v1}")
|
||||
await context.storage_state(path=Path(BASE_DIR / "cookiesFile" / f"{uuid_v1}.json"))
|
||||
# 确保cookiesFile目录存在
|
||||
cookies_dir = Path(BASE_DIR / "cookiesFile")
|
||||
cookies_dir.mkdir(exist_ok=True)
|
||||
await context.storage_state(path=cookies_dir / f"{uuid_v1}.json")
|
||||
result = await check_cookie(2,f"{uuid_v1}.json")
|
||||
if not result:
|
||||
status_queue.put("500")
|
||||
@@ -196,7 +202,10 @@ async def get_ks_cookie(id,status_queue):
|
||||
return None
|
||||
uuid_v1 = uuid.uuid1()
|
||||
print(f"UUID v1: {uuid_v1}")
|
||||
await context.storage_state(path=Path(BASE_DIR / "cookiesFile" / f"{uuid_v1}.json"))
|
||||
# 确保cookiesFile目录存在
|
||||
cookies_dir = Path(BASE_DIR / "cookiesFile")
|
||||
cookies_dir.mkdir(exist_ok=True)
|
||||
await context.storage_state(path=cookies_dir / f"{uuid_v1}.json")
|
||||
result = await check_cookie(4, f"{uuid_v1}.json")
|
||||
if not result:
|
||||
status_queue.put("500")
|
||||
@@ -267,7 +276,10 @@ async def xiaohongshu_cookie_gen(id,status_queue):
|
||||
return None
|
||||
uuid_v1 = uuid.uuid1()
|
||||
print(f"UUID v1: {uuid_v1}")
|
||||
await context.storage_state(path=Path(BASE_DIR / "cookiesFile" / f"{uuid_v1}.json"))
|
||||
# 确保cookiesFile目录存在
|
||||
cookies_dir = Path(BASE_DIR / "cookiesFile")
|
||||
cookies_dir.mkdir(exist_ok=True)
|
||||
await context.storage_state(path=cookies_dir / f"{uuid_v1}.json")
|
||||
result = await check_cookie(1, f"{uuid_v1}.json")
|
||||
if not result:
|
||||
status_queue.put("500")
|
||||
|
||||
Reference in New Issue
Block a user