b3b6b702d1
- publish_gatekeeper.py (neues Gatekeeper-System) - 4 Premium-Artikel: Veggie Match, Berlin 1960, Wild Tiled West, Scream Park - Alle kumulierten Artikel, Scripts, Medien und Caches
38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Get full news page snapshots for article context."""
|
|
import subprocess
|
|
import re
|
|
import time
|
|
|
|
AGENT_BROWSER = "/home/hermes/.hermes/node/lib/node_modules/agent-browser/bin/agent-browser-linux-x64"
|
|
|
|
def run(cmd, timeout=15):
|
|
result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=timeout)
|
|
return result.stdout
|
|
|
|
for news_id in [1101, 1103]:
|
|
run(f'{AGENT_BROWSER} close --all 2>/dev/null', timeout=3)
|
|
print(f"\n=== News ID {news_id} ===")
|
|
run(f'{AGENT_BROWSER} open "https://en.boardgamearena.com/news?id={news_id}" --args "--no-sandbox"', timeout=20)
|
|
time.sleep(2)
|
|
snap = run(f'{AGENT_BROWSER} snapshot', timeout=15)
|
|
|
|
with open(f'/home/hermes/workspace/bga_news_{news_id}.txt', 'w') as f:
|
|
f.write(snap)
|
|
|
|
# Extract paragraphs after the heading
|
|
# Find the game description text - typically StaticText paragraphs
|
|
texts = re.findall(r'StaticText\s+\"([^\"]{30,})\"', snap)
|
|
|
|
print(f" Title: {re.findall(r'heading\s+\"([^\"]+)\"\s+\[level=3', snap)}")
|
|
print(f" Date: {re.findall(r'StaticText\s+\"(\w+\s+\d+(?:st|nd|rd|th)\s+\d{4})\"', snap)[:5]}")
|
|
print(f" Long texts ({len(texts)} found):")
|
|
for i, t in enumerate(texts[:15]):
|
|
if len(t) > 30:
|
|
print(f" [{i}] ({len(t)} chars) {t[:200]}...")
|
|
|
|
run(f'{AGENT_BROWSER} close --all 2>/dev/null', timeout=3)
|
|
time.sleep(1)
|
|
|
|
print("\nDone.")
|