基本完成
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
"""探测卡片上 boss 在线绿点的 DOM 选择器"""
|
||||
import json
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
from client.browser.applicant import _select_expect_js
|
||||
from client.browser.cdp_lite import LiteCDP, CDPSession
|
||||
from client.browser.manager import BrowserManager
|
||||
|
||||
OUT = Path(__file__).resolve().parent / "data" / "debug" / "在线标记排查.txt"
|
||||
|
||||
_lines: list[str] = []
|
||||
|
||||
|
||||
def log(*a):
|
||||
s = " ".join(str(x) for x in a)
|
||||
_lines.append(s)
|
||||
OUT.write_text("\n".join(_lines), encoding="utf-8")
|
||||
|
||||
|
||||
def main():
|
||||
BrowserManager().ensure_browser_started()
|
||||
lite = LiteCDP()
|
||||
|
||||
tab = lite.open_tab("https://www.zhipin.com/web/geek/jobs")
|
||||
time.sleep(8)
|
||||
s = CDPSession(tab["webSocketDebuggerUrl"])
|
||||
|
||||
info = json.loads(s.eval_js(_select_expect_js("java", "北京")) or "{}")
|
||||
if info.get("ok"):
|
||||
s.click_at(info["x"], info["y"])
|
||||
time.sleep(6)
|
||||
|
||||
log("1) 前 4 张卡片 footer 结构:", s.eval_js("""JSON.stringify(
|
||||
[...document.querySelectorAll('.job-card-wrap')].slice(0, 4).map(el => {
|
||||
const f = el.querySelector('.job-card-footer') || el;
|
||||
return f.outerHTML.replace(/\\s+/g, ' ').slice(0, 700);
|
||||
}))"""))
|
||||
|
||||
log("2) 疑似在线标记元素:", s.eval_js("""JSON.stringify(
|
||||
[...document.querySelectorAll('.job-card-wrap')].slice(0, 6).map(el => {
|
||||
const dots = [...el.querySelectorAll('*')].filter(d => {
|
||||
const cls = String(d.className || '');
|
||||
return /online|active|green|status/i.test(cls);
|
||||
}).map(d => String(d.className));
|
||||
const boss = el.querySelector('.boss-info');
|
||||
return {dots: dots, boss_html: boss ? boss.outerHTML.replace(/\\s+/g, ' ').slice(0, 400) : null};
|
||||
}))"""))
|
||||
|
||||
s.close()
|
||||
lite.close_tab(tab["id"])
|
||||
log("完成")
|
||||
print("排查完成 ->", OUT)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user