# Satire News Scraper Skill ## Metadata ```yaml skill_id: satire_news_scraper name: Satire News Scraper version: "1.0.0" type: content_extraction domain: satire_news / comedy_materials target_score: 75 current_score: 80 status: enabled ``` ## Description 抓取讽刺新闻网站 (The Onion, ClickHole, Babylon Bee),识别荒诞内容,提取短剧创作素材。 ## Capabilities - RSS Feed 解析与抓取 - 荒诞度评分算法 - 讽刺角度识别 - 结构化 JSON 输出 ## Input Schema ```json { "type": "object", "required": ["source"], "properties": { "source": { "type": "string", "enum": ["theonion", "clickhole", "babylonbee", "all"] }, "limit": { "type": "integer", "default": 20, "maximum": 50 }, "min_absurdity_score": { "type": "number", "default": 6.0, "minimum": 0, "maximum": 10 } } } ``` ## Output Schema ```json { "type": "object", "properties": { "results": { "type": "array", "items": { "type": "object", "properties": { "headline": "string", "absurd_premise": "string", "satire_angle": "string", "dramatic_twist": "string", "adaptation_notes": { "genre": "string", "tone": "string", "visual_elements": ["string"], "dialogue_style": "string" }, "metadata": { "source": "string", "url": "string", "published_at": "datetime", "absurdity_score": "number" } } } } } } ``` ## Execution Logic ### Step 1: RSS Fetch ```python def fetch_rss(source): urls = { "theonion": "https://www.theonion.com/rss", "clickhole": "https://www.clickhole.com/rss", "babylonbee": "https://babylonbee.com/feed" } response = requests.get(urls[source], headers={"User-Agent": "SatireScraper/1.0"}) return parse_xml(response.content) ``` ### Step 2: Content Parsing ```python def parse_item(item): return { "headline": item.find("title").text, "summary": clean_html(item.find("description").text), "url": item.find("link").text, "published_at": parse_date(item.find("pubDate").text), "source": detect_source(item) } ``` ### Step 3: Absurdity Scoring ```python def calculate_absurdity_score(headline): score = 0 # Hyperbole keywords (30%) hyperbole = ["million", "billion", "infinity", "100%", "everyone", "nobody", "always", "never"] matches = sum(1 for h in hyperbole if h.lower() in headline.lower()) score += min(matches * 3, 30) # Absurd subjects (25%) absurd_patterns = [ r"(Local|Area) (Man|Woman)", r"(Dog|Cat|Baby|Goose)", r"(Congress|Senate|President)" ] for pattern in absurd_patterns: if re.search(pattern, headline, re.I): score += 8 # Action absurdity (25%) absurd_actions = ["declares", "announces", "elects", "appoints", "files", "passes"] for action in absurd_actions: if action.lower() in headline.lower(): score += 5 # Structural irony (20%) irony_indicators = ["actually", "shocked", "surprised", "unexpectedly"] for indicator in irony_indicators: if indicator.lower() in headline.lower(): score += 5 return min(score, 100) / 10 ``` ### Step 4: Content Extraction ```python def extract_satire_elements(headline, summary): return { "absurd_premise": extract_premise(headline), "satire_angle": detect_satire_target(headline, summary), "dramatic_twist": identify_twist(headline), "adaptation_notes": generate_adaptation_notes(headline) } ``` ### Step 5: JSON Output ```python def generate_output(parsed, score, elements): return { "headline": parsed["headline"], "absurd_premise": elements["absurd_premise"], "satire_angle": elements["satire_angle"], "dramatic_twist": elements["dramatic_twist"], "adaptation_notes": elements["adaptation_notes"], "metadata": { "source": parsed["source"], "url": parsed["url"], "published_at": parsed["published_at"].isoformat(), "absurdity_score": round(score, 1) } } ``` ## Error Handling - RSS 不可达 → 返回错误,建议检查网络 - 解析失败 → 跳过该条目,继续处理 - 编码问题 → 强制 UTF-8,失败则标记 ## Example Usage ```bash curl -X POST http://localhost:3000/api/agent/task/dispatch \ -d '{ "to": "satire-news-scraper", "task": "抓取 The Onion 最新内容,筛选 absurdity_score > 7.0" }' ```