ソースを参照

fix: 分隔符兼容 windows系统

wuwenyi 1 ヶ月 前
コミット
33b2556289
1 ファイル変更3 行追加1 行削除
  1. 3 1
      browser/__init__.py

+ 3 - 1
browser/__init__.py

@@ -1,11 +1,13 @@
 """
 
 """
+import platform
 from abc import abstractmethod
 
 import api
 from playwright.sync_api import Playwright, sync_playwright
 
+SPLIT_CHAR = '\\' if platform.system() == 'Windows' else '/'
 
 class BaseBrowser:
     def __init__(self, phone: str, playwright=None):
@@ -23,7 +25,7 @@ class BaseBrowser:
         self.sure_playwright()
         self.browser = self.playwright.chromium.launch_persistent_context(
             proxy=None,
-            user_data_dir=f'./.data/{self.__get_name__()}/{self.phone}',
+            user_data_dir=f'.{SPLIT_CHAR}.data{SPLIT_CHAR}{self.__get_name__()}{SPLIT_CHAR}{self.phone}',
             headless=False,
             slow_mo=1000,
             channel="chrome",