tune: read_timeout 60s, simphtml print/newTabs fix, remove obsolete iframe sop
This commit is contained in:
@@ -421,7 +421,7 @@ class BaseSession:
|
||||
self.proxies = {"http": proxy, "https": proxy} if proxy else None
|
||||
self.max_retries = max(0, int(cfg.get('max_retries', 2)))
|
||||
self.connect_timeout = max(1, int(cfg.get('connect_timeout', 10)))
|
||||
self.read_timeout = max(5, int(cfg.get('read_timeout', 120)))
|
||||
self.read_timeout = max(5, int(cfg.get('read_timeout', 60)))
|
||||
effort = cfg.get('reasoning_effort')
|
||||
effort = None if effort is None else str(effort).strip().lower()
|
||||
self.reasoning_effort = effort if effort in ('none', 'minimal', 'low', 'medium', 'high', 'xhigh') else None
|
||||
|
||||
@@ -114,13 +114,6 @@ web_execute_js script='{"cmd": "batch", "commands": [...]}'
|
||||
- simphtml:`str(simphtml.optimize_html_for_tokens(html))` — 返回BS4 Tag需str()
|
||||
- ⚠**DOMRect坑(hasOverlap)**:某些上下文`rect.x/y`为undefined(只有left/top),导致NaN→误判重叠。兼容:`rect.x ?? rect.left`
|
||||
|
||||
## 跨域iframe操控(postMessage中继)
|
||||
- 扩展content script支持:顶层发postMessage到iframe,iframe内eval+回传结果
|
||||
- 顶层发送:`iframe.contentWindow.postMessage({type:'ljq_exec', id, code}, '*')`
|
||||
- iframe回传:`{type:'ljq_result', id, result}` 通过window.addEventListener('message')接收
|
||||
- ⚠只能eval表达式,不支持return/函数体包装
|
||||
- 已验证:读取iframe内DOM、填写input均成功
|
||||
|
||||
## 连不上排查
|
||||
web_scan失败时按序排查:
|
||||
①扩展没装?→检查Chrome扩展列表(chrome://extensions)是否有TMWebDriver扩展
|
||||
|
||||
@@ -734,7 +734,7 @@ def get_html(driver, cutlist=False, maxchars=35000, instruction="", extra_js="",
|
||||
if keep: keep[-1].insert_after(hint_tag)
|
||||
for it in removed: it.decompose()
|
||||
ss = str(optimize_html_for_tokens(soup)) if lists else html
|
||||
if lists: print(f"[cutlist] Result: {len(html)} -> {len(ss)} chars ({100-len(ss)*100//len(html)}% saved)")
|
||||
print(f"[get_html] Result: {len(html)} -> {len(ss)} chars after cutlist ({100-len(ss)*100//len(html)}% saved)")
|
||||
if len(ss) > maxchars: ss = str(smart_truncate(soup, maxchars))
|
||||
return ss
|
||||
|
||||
@@ -844,7 +844,7 @@ def execute_js_rich(script, driver, no_monitor=False):
|
||||
new_sids = {k: v for k, v in after.items() if k not in before_sids}
|
||||
if new_sids:
|
||||
newTabs = [{'id': k, 'url': v} for k, v in new_sids.items()]
|
||||
rr['environment']['newTabs'] = newTabs
|
||||
rr['newTabs'] = newTabs
|
||||
rr['suggestion'] = "页面已刷新,以上新标签页在执行期间连接。"
|
||||
if error_msg: rr['error'] = error_msg
|
||||
if no_monitor: return rr
|
||||
|
||||
Reference in New Issue
Block a user