observe_996box_login.py 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. """Observe 996box login page: screenshot + dump login form HTML.
  2. No interaction, no risk. Just open the page in Edge and report what's there.
  3. """
  4. import asyncio
  5. import sys
  6. from pathlib import Path
  7. _HERE = Path(__file__).resolve().parent
  8. sys.path.insert(0, str(_HERE.parent / "src"))
  9. from playwright.async_api import async_playwright
  10. EDGE = r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
  11. URL = "https://pc.hzwlan.com/login/account"
  12. async def main():
  13. out = _HERE / "jfbym_diag"
  14. out.mkdir(exist_ok=True)
  15. async with async_playwright() as p:
  16. browser = await p.chromium.launch(
  17. executable_path=EDGE, headless=True,
  18. args=["--disable-blink-features=AutomationControlled"],
  19. )
  20. ctx = await browser.new_context(
  21. viewport={"width": 1366, "height": 768},
  22. user_agent=("Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 "
  23. "(KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 "
  24. "Edg/108.0.1462.54"),
  25. )
  26. page = await ctx.new_page()
  27. await page.goto(URL, wait_until="networkidle", timeout=30000)
  28. await page.wait_for_timeout(1500)
  29. # Full page screenshot
  30. shot = out / "996box_login_full.png"
  31. await page.screenshot(path=str(shot), full_page=True)
  32. print(f"screenshot: {shot} ({shot.stat().st_size // 1024} KB)")
  33. # URL after load (sometimes redirects)
  34. print(f"final URL: {page.url}")
  35. # Dump all buttons + inputs + tabs with their text
  36. info = await page.evaluate("""() => {
  37. const r = {url: location.href, title: document.title};
  38. r.buttons = [...document.querySelectorAll('button')].map(b => ({
  39. tag: b.tagName, cls: b.className, text: (b.innerText||'').trim().slice(0,40),
  40. type: b.type, id: b.id, name: b.name, visible: b.offsetParent !== null
  41. }));
  42. r.inputs = [...document.querySelectorAll('input')].map(i => ({
  43. tag: i.tagName, type: i.type, cls: i.className, id: i.id,
  44. name: i.name, placeholder: i.placeholder, value: i.value
  45. }));
  46. r.tabs = [...document.querySelectorAll('[role=tab], .ant-tabs-tab')].map(t => ({
  47. tag: t.tagName, cls: t.className, text: (t.innerText||'').trim().slice(0,40),
  48. active: t.classList.contains('ant-tabs-tab-active')
  49. }));
  50. r.geetest = !!document.querySelector('.geetest_') || !!document.querySelector('iframe[src*="geetest"]');
  51. r.body_class = document.body.className;
  52. r.form_count = document.querySelectorAll('form').length;
  53. return r;
  54. }""")
  55. print(f"\ntitle: {info['title']}")
  56. print(f"body_class: {info['body_class']}")
  57. print(f"geetest_present: {info['geetest']}")
  58. print(f"form_count: {info['form_count']}")
  59. print(f"\n--- buttons ({len(info['buttons'])}) ---")
  60. for b in info["buttons"]:
  61. print(f" <{b['tag']} class='{b['cls'][:60]}' type={b['type']} id={b['id']!r}> "
  62. f"text='{b['text']}' visible={b['visible']}")
  63. print(f"\n--- inputs ({len(info['inputs'])}) ---")
  64. for i in info["inputs"]:
  65. print(f" <{i['tag']} type='{i['type']}' id='{i['id']}' name='{i['name']}' "
  66. f"placeholder='{i['placeholder']}'>")
  67. print(f"\n--- tabs ({len(info['tabs'])}) ---")
  68. for t in info["tabs"]:
  69. print(f" <{t['tag']} class='{t['cls'][:50]}' active={t['active']}> text='{t['text']}'")
  70. await browser.close()
  71. asyncio.run(main())