59 lines
2.2 KiB
Python
59 lines
2.2 KiB
Python
"""Run this script once with a Teams meeting chat open.
|
|
It prints DOM info to identify selectors for messages and profile cards.
|
|
|
|
Usage:
|
|
.venv/bin/python scripts/discover_dom.py [teams-chat-url]
|
|
"""
|
|
import sys
|
|
from pathlib import Path
|
|
from playwright.sync_api import sync_playwright
|
|
|
|
URL = sys.argv[1] if len(sys.argv) > 1 else "https://teams.microsoft.com"
|
|
SESSION_DIR = str(Path.home() / ".teampulse" / "session")
|
|
|
|
|
|
def main():
|
|
with sync_playwright() as p:
|
|
browser = p.chromium.launch_persistent_context(
|
|
SESSION_DIR,
|
|
headless=False,
|
|
args=["--no-sandbox"],
|
|
)
|
|
page = browser.pages[0] if browser.pages else browser.new_page()
|
|
page.goto(URL)
|
|
print("Navigiere im Browser zu einem Meeting-Chat, dann hier Enter drücken...")
|
|
input()
|
|
|
|
candidates = page.query_selector_all(
|
|
"[data-tid*='message'], [class*='message'], [role='listitem']"
|
|
)
|
|
print(f"\n{len(candidates)} potenzielle Nachrichten-Elemente gefunden")
|
|
for i, el in enumerate(candidates[:5]):
|
|
print(f"\n--- Element {i} ---")
|
|
print(f" tag: {el.evaluate('e => e.tagName')}")
|
|
print(f" data-tid: {el.get_attribute('data-tid')}")
|
|
print(f" class (100 Zch): {(el.get_attribute('class') or '')[:100]}")
|
|
print(f" text (100 Zch): {el.inner_text()[:100].replace(chr(10), ' ')}")
|
|
|
|
print("\nKlicke im Browser auf einen Sender-Namen, dann hier Enter drücken...")
|
|
input()
|
|
|
|
cards = page.query_selector_all(
|
|
"[class*='persona'], [class*='Persona'], [class*='profile'], [data-tid*='persona']"
|
|
)
|
|
print(f"\n{len(cards)} potenzielle Profilkarten-Elemente gefunden")
|
|
for i, el in enumerate(cards[:5]):
|
|
print(f"\n--- Karte {i} ---")
|
|
print(f" tag: {el.evaluate('e => e.tagName')}")
|
|
print(f" data-tid: {el.get_attribute('data-tid')}")
|
|
print(f" class (100 Zch): {(el.get_attribute('class') or '')[:100]}")
|
|
print(f" text (100 Zch): {el.inner_text()[:100].replace(chr(10), ' ')}")
|
|
|
|
print("\nEnter zum Schließen...")
|
|
input()
|
|
browser.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|