fix: os.startfile is Windows-only, use webbrowser.open to wake the browser (#598)
web driver init nudges the browser by opening a page when no session appears; os.startfile raises AttributeError on Linux/macOS, killing the retry loop on headless servers. webbrowser.open is stdlib and cross-platform with the same effect.
This commit is contained in:
1 parent
262614cafd
commit
f43ea23ccf
1 file changed
+2
-2
@@ -1,4 +1,4 @@
|
||||
import sys, os, re, json, time, threading, importlib
|
||||
import sys, os, re, json, time, threading, importlib, webbrowser
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
import tempfile, traceback, subprocess, itertools, collections, difflib, shutil
|
||||
@@ -112,7 +112,7 @@ def first_init_driver():
|
||||
time.sleep(2)
|
||||
sess = driver.get_all_sessions()
|
||||
if len(sess) > 0: break
|
||||
if i == 4: os.startfile("https://example.com")
|
||||
if i == 4: webbrowser.open("https://example.com")
|
||||
|
||||
def web_scan(tabs_only=False, switch_tab_id=None, text_only=False, maxlen=35000):
|
||||
"""获取当前页面的简化HTML内容和标签页列表。注意:简化过程会过滤边栏、浮动元素等非主体内容。
|
||||
|
||||
Reference in new issue
Block a user