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
92 lines
2.8 KiB
Python
92 lines
2.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Scrape BGA news IDs 1101-1115 for new game releases."""
|
|
import subprocess
|
|
import re
|
|
import json
|
|
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
|
|
|
|
results = []
|
|
|
|
for news_id in range(1101, 1116):
|
|
# Close any existing session first
|
|
run(f'{AGENT_BROWSER} close --all 2>/dev/null', timeout=3)
|
|
|
|
print(f"--- Scraping ID {news_id} ---")
|
|
|
|
# Open the news page
|
|
open_out = run(f'{AGENT_BROWSER} open "https://en.boardgamearena.com/news?id={news_id}" --args "--no-sandbox"', timeout=20)
|
|
|
|
# Get snapshot
|
|
time.sleep(2)
|
|
snap = run(f'{AGENT_BROWSER} snapshot', timeout=15)
|
|
snap_len = len(snap)
|
|
print(f" Snapshot length: {snap_len}")
|
|
|
|
if snap_len < 1000:
|
|
print(f" ID {news_id}: EMPTY or too short, skipping")
|
|
continue
|
|
|
|
# Extract heading (level 3)
|
|
headings = re.findall(r'heading\s+\"([^\"]+)\"\s+\[level=3', snap)
|
|
title = headings[0] if headings else None
|
|
|
|
# Extract date (Month DDth YYYY)
|
|
dates = re.findall(r'StaticText\s+\"(\w+\s+\d+(?:st|nd|rd|th)\s+\d{4})\"', snap)
|
|
date = dates[-1] if dates else None
|
|
|
|
# Extract gamepanel links
|
|
gamepanels = re.findall(r'link\s+\"(https://boardgamearena\.com/gamepanel\?game=[^\"]+)\"', snap)
|
|
|
|
# Also look for any links
|
|
links = re.findall(r'link\s+\"(https://[^\"]+)\"', snap)
|
|
|
|
if title:
|
|
print(f" TITLE: {title}")
|
|
if date:
|
|
print(f" DATE: {date}")
|
|
if gamepanels:
|
|
print(f" GAMEPANEL: {gamepanels[0]}")
|
|
|
|
# Filter: skip non-game content
|
|
skip = False
|
|
if title:
|
|
if "arena season" in title.lower():
|
|
print(f" SKIP: Arena Season")
|
|
skip = True
|
|
elif "bga award" in title.lower():
|
|
print(f" SKIP: BGA Award")
|
|
skip = True
|
|
elif "board game fest" in title.lower() or "celebrate" in title.lower():
|
|
print(f" SKIP: Board Game Fest")
|
|
skip = True
|
|
|
|
if title and date and not skip:
|
|
result = {
|
|
"id": news_id,
|
|
"date": date,
|
|
"title": title,
|
|
"gamepanel": gamepanels[0] if gamepanels else None
|
|
}
|
|
results.append(result)
|
|
print(f" RESULT: {json.dumps(result)}")
|
|
|
|
# Close before next
|
|
run(f'{AGENT_BROWSER} close --all 2>/dev/null', timeout=3)
|
|
time.sleep(1)
|
|
|
|
print("\n=== ALL RESULTS ===")
|
|
for r in results:
|
|
print(json.dumps(r, ensure_ascii=False))
|
|
|
|
# Save to file
|
|
with open('/home/hermes/workspace/bga_new_games.json', 'w') as f:
|
|
json.dump(results, f, indent=2, ensure_ascii=False)
|
|
|
|
print(f"\nTotal new games found: {len(results)}")
|