优化路径,增加手动登录时间限制
This commit is contained in:
parent
f51278742c
commit
fdd79b6931
@ -217,10 +217,17 @@ class DouyinPlayVVScraper:
|
||||
if env_override:
|
||||
candidates.append(env_override)
|
||||
logging.info(f'检测到环境变量 OVERRIDE_CHROMEDRIVER,优先使用: {env_override}')
|
||||
# 优先使用用户提供的路径
|
||||
# 脚本所在目录的drivers路径(优先)
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
script_driver_path = os.path.join(script_dir, 'drivers', 'chromedriver.exe')
|
||||
candidates.append(script_driver_path)
|
||||
logging.info(f'优先尝试脚本目录路径: {script_driver_path}')
|
||||
|
||||
# 项目根目录的drivers路径
|
||||
user_driver_path = os.path.join(os.getcwd(), 'drivers', 'chromedriver.exe')
|
||||
candidates.append(user_driver_path)
|
||||
logging.info(f'优先尝试用户提供路径: {user_driver_path}')
|
||||
logging.info(f'尝试项目根目录路径: {user_driver_path}')
|
||||
|
||||
# 项目根目录
|
||||
candidates.append(os.path.join(os.getcwd(), 'chromedriver.exe'))
|
||||
# 其他可能目录
|
||||
@ -278,7 +285,7 @@ class DouyinPlayVVScraper:
|
||||
def navigate(self):
|
||||
logging.info(f'导航到: {self.start_url}')
|
||||
self.driver.get(self.start_url)
|
||||
time.sleep(3)
|
||||
time.sleep(8) # 增加页面加载等待时间
|
||||
|
||||
def ensure_login(self):
|
||||
"""确保用户已登录并导航到收藏合集页面"""
|
||||
@ -328,7 +335,7 @@ class DouyinPlayVVScraper:
|
||||
logging.warning(f"检测URL时出错: {e}。请重试。")
|
||||
time.sleep(1)
|
||||
|
||||
def _check_login_and_page(self, timeout: int = 30) -> bool:
|
||||
def _check_login_and_page(self, timeout: int = 600) -> bool:
|
||||
"""检查是否已登录并在正确页面"""
|
||||
try:
|
||||
current_url = self.driver.current_url
|
||||
@ -351,7 +358,7 @@ class DouyinPlayVVScraper:
|
||||
logging.warning(f"检查登录状态时出错: {e}")
|
||||
return False
|
||||
|
||||
def _detect_login_status(self, timeout: int = 30) -> bool:
|
||||
def _detect_login_status(self, timeout: int = 600) -> bool:
|
||||
"""自动检测是否已登录"""
|
||||
try:
|
||||
start = time.time()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user