fix: <style>-Blöcke aus allen 24 Artikeln entfernt + Skill korrigiert
- artikel_*.html: 24 Dateien von <style>-Blöcken befreit (body, max-width zerstören Joomla) - journalistic-article-writing SKILL.md: falsche 'AUSNAHME 09.07.' entfernt - Ursache: Skill-Kommentar erlaubte Sub-Agenten <style> 'für Vorschau' — kein Gatekeeper existiert
This commit is contained in:
+102
@@ -0,0 +1,102 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Wrapper to run reddit_scraper with current dates (last 3 days)."""
|
||||
import sys
|
||||
sys.path.insert(0, '/home/hermes/workspace')
|
||||
|
||||
from datetime import date, datetime, timezone
|
||||
import json
|
||||
import time
|
||||
|
||||
# Import the scraper module
|
||||
import reddit_scraper
|
||||
|
||||
# Override target dates to last 3 days
|
||||
today = date.today() # 2026-07-03
|
||||
target_dates = {today - date.resolution * i for i in range(3)}
|
||||
print(f"Target dates: {sorted(target_dates)}", file=sys.stderr)
|
||||
|
||||
# Run the scraping
|
||||
urls = [
|
||||
"https://old.reddit.com/r/boardgames/",
|
||||
"https://old.reddit.com/r/boardgames/new/",
|
||||
"https://old.reddit.com/r/boardgames/rising/",
|
||||
]
|
||||
|
||||
all_posts = []
|
||||
for url in urls:
|
||||
print(f"Fetching: {url}", file=sys.stderr)
|
||||
try:
|
||||
html = reddit_scraper.fetch_html(url)
|
||||
posts = reddit_scraper.extract_posts(html)
|
||||
print(f" Extracted {len(posts)} posts", file=sys.stderr)
|
||||
|
||||
existing_ids = {p["id"] for p in all_posts}
|
||||
for p in posts:
|
||||
if p["id"] not in existing_ids:
|
||||
all_posts.append(p)
|
||||
existing_ids.add(p["id"])
|
||||
except Exception as e:
|
||||
print(f" Error: {e}", file=sys.stderr)
|
||||
time.sleep(1)
|
||||
|
||||
print(f"\nTotal unique raw posts: {len(all_posts)}", file=sys.stderr)
|
||||
|
||||
# List all dates found
|
||||
dates_found = set()
|
||||
for p in all_posts:
|
||||
if p.get("timestamp_utc"):
|
||||
dates_found.add(p["timestamp_utc"].date())
|
||||
print(f"Dates found: {sorted(dates_found)}", file=sys.stderr)
|
||||
|
||||
filtered = reddit_scraper.filter_posts(all_posts, target_dates)
|
||||
print(f"After filtering: {len(filtered)} posts", file=sys.stderr)
|
||||
|
||||
# Sort by score desc
|
||||
filtered.sort(key=lambda p: p.get("score", 0), reverse=True)
|
||||
filtered = filtered[:30]
|
||||
|
||||
output = []
|
||||
for i, post in enumerate(filtered, 1):
|
||||
output.append({
|
||||
"rank": i,
|
||||
"title": post["title"],
|
||||
"score": post["score"],
|
||||
"comments": post["comments"],
|
||||
"flair": post.get("flair", ""),
|
||||
"author": post.get("author", ""),
|
||||
"date": post.get("date_str", ""),
|
||||
"url": post.get("permalink", ""),
|
||||
"domain": post.get("domain", ""),
|
||||
})
|
||||
|
||||
# Save JSON
|
||||
with open("/home/hermes/workspace/boardgames_recent_posts.json", "w") as f:
|
||||
json.dump(output, f, indent=2, ensure_ascii=False)
|
||||
|
||||
print(json.dumps(output, indent=2, ensure_ascii=False))
|
||||
|
||||
# Summary
|
||||
print("\n" + "="*80, file=sys.stderr)
|
||||
print(f"TOP {len(output)} POSTS (last 3 days) from r/boardgames", file=sys.stderr)
|
||||
print("="*80, file=sys.stderr)
|
||||
|
||||
news_posts = [p for p in output if p["flair"] == "News"]
|
||||
reviews = [p for p in output if p["flair"] == "Review"]
|
||||
ks_posts = [p for p in output if "kickstarter" in p["title"].lower() or "crowdfunding" in p["title"].lower()]
|
||||
|
||||
if news_posts:
|
||||
print("\n📰 NEWS:", file=sys.stderr)
|
||||
for p in news_posts:
|
||||
print(f" • {p['title']} (🔺{p['score']}, 💬{p['comments']})", file=sys.stderr)
|
||||
if reviews:
|
||||
print("\n📝 REVIEWS:", file=sys.stderr)
|
||||
for p in reviews:
|
||||
print(f" • {p['title']} (🔺{p['score']}, 💬{p['comments']})", file=sys.stderr)
|
||||
if ks_posts:
|
||||
print("\n💰 KICKSTARTER/CROWDFUNDING:", file=sys.stderr)
|
||||
for p in ks_posts:
|
||||
print(f" • {p['title']} (🔺{p['score']}, 💬{p['comments']})", file=sys.stderr)
|
||||
|
||||
print(f"\n📊 Total: {len(output)} posts", file=sys.stderr)
|
||||
print(f"📅 Date range: {min(target_dates)} to {max(target_dates)}", file=sys.stderr)
|
||||
print(f"📄 JSON saved to: /home/hermes/workspace/boardgames_recent_posts.json", file=sys.stderr)
|
||||
Reference in New Issue
Block a user