Files
BSN-Chatsystem/bgg-scrape/fetch_extra.py
T

30 lines
868 B
Python

import subprocess
import sys
API_KEY="de3b01db-9be3-4c80-bd80-d47e071b320e"
UA = "BSN-OpenClaw/1.0 (Brettspiel-News.de; kontakt@brettspiel-news.de)"
forums = {
25: "Articles & Blogs",
30: "Videos & Podcasts",
26: "Board Game Design",
}
for fid, fname in forums.items():
url = f"https://boardgamegeek.com/xmlapi2/forum?id={fid}&page=1"
cmd = [
"curl", "-s", "--max-time", "15",
"-H", f"User-Agent: {UA}",
"-H", f"Authorization: Bearer {API_KEY}",
url,
]
result = subprocess.run(cmd, capture_output=True, text=True)
outfile = f"/home/hermes/workspace/bgg-scrape/forum{fid}.xml"
with open(outfile, "w") as f:
f.write(result.stdout)
thread_count = result.stdout.count("<thread ")
print(f"Forum {fid} ({fname}): {len(result.stdout)} bytes, {thread_count} threads")
print("Done.")