Parcourir la source

fix: 分隔符兼容 windows系统

wuwenyi il y a 1 mois
Parent
commit
33b2556289
1 fichiers modifiés avec 3 ajouts et 1 suppressions
  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",