补充日志
This commit is contained in:
@@ -83,17 +83,30 @@ _JD_JS = """(() => {
|
||||
|
||||
|
||||
def _select_expect_js(keyword: str, city_name: str) -> str:
|
||||
"""在期望条件栏查找目标期望(优先 关键词(城市) 全匹配,其次城市匹配),返回坐标供可信点击"""
|
||||
"""在期望条件栏查找目标期望(优先 关键词(城市) 全匹配,其次城市匹配),
|
||||
返回坐标及落点校验/全量期望项坐标,供可信点击与问题排查"""
|
||||
return ("((kw, city) => (() => {"
|
||||
"const items = [...document.querySelectorAll('.expect-item')];"
|
||||
"const txt = el => ((el.querySelector('.text-content') || el).innerText || '').trim();"
|
||||
"const rect = el => { const r = el.getBoundingClientRect();"
|
||||
" return {x: Math.round(r.x), y: Math.round(r.y),"
|
||||
" w: Math.round(r.width), h: Math.round(r.height)}; };"
|
||||
"let hit = city && items.find(el => txt(el) === kw + '(' + city + ')');"
|
||||
"if (!hit && city) hit = items.find(el => txt(el).endsWith('(' + city + ')'));"
|
||||
"if (!hit && kw) hit = items.find(el => txt(el).toLowerCase().includes(kw.toLowerCase()));"
|
||||
"if (!hit) return JSON.stringify({ok: false, list: items.map(txt)});"
|
||||
"const r = hit.getBoundingClientRect();"
|
||||
"const cx = r.x + r.width / 2, cy = r.y + r.height / 2;"
|
||||
# 落点校验:坐标处实际压着的元素(若被浮层/筛选栏遮挡会暴露)
|
||||
"const at = document.elementFromPoint(cx, cy);"
|
||||
"return JSON.stringify({ok: true, text: txt(hit),"
|
||||
" x: r.x + r.width / 2, y: r.y + r.height / 2});"
|
||||
" x: Math.round(cx), y: Math.round(cy),"
|
||||
" w: Math.round(r.width), h: Math.round(r.height),"
|
||||
" atPoint: at ? {tag: at.tagName, cls: String(at.className).slice(0, 80),"
|
||||
" text: (at.innerText || '').trim().slice(0, 40)} : null,"
|
||||
" items: items.map(el => ({text: txt(el), ...rect(el)})),"
|
||||
" view: {iw: window.innerWidth, ih: window.innerHeight,"
|
||||
" sy: Math.round(window.scrollY)}});"
|
||||
"})())(" + json.dumps(keyword, ensure_ascii=False) + ","
|
||||
+ json.dumps(city_name, ensure_ascii=False) + ")")
|
||||
|
||||
@@ -300,6 +313,13 @@ class Applicant:
|
||||
f"({city_name or '未配置城市名'}),"
|
||||
f"现有期望:{info.get('list') or '无'}")
|
||||
return False
|
||||
# 定位详情:目标坐标/尺寸 + 坐标处实际压着的元素 + 全部期望项坐标 + 视口状态
|
||||
logger.debug(f"期望定位:目标「{info.get('text')}」中心坐标"
|
||||
f"({info.get('x')},{info.get('y')})"
|
||||
f" 尺寸{info.get('w')}x{info.get('h')}"
|
||||
f" 落点元素={info.get('atPoint')}"
|
||||
f" 视口={info.get('view')}")
|
||||
logger.debug(f"期望栏全部项坐标:{info.get('items')}")
|
||||
self._sess.human_click(info["x"], info["y"])
|
||||
logger.info(f"已选中期望条件:{info.get('text')}")
|
||||
time.sleep(2)
|
||||
|
||||
Reference in New Issue
Block a user