OpenSenseNova/SenseNova-Skills / skills/sn-search-social-media
sn-search-social-media
Verified搜索社区、社媒、新闻热点、百科趋势、开发者生态和技术讨论时使用。
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 5.4 KB |
| requirements.txt | manifest | 12 B |
| scripts/_filters.py | script | 1.6 KB |
| scripts/github_public_search.py | script | 3.8 KB |
| scripts/hackernews_hotspots.py | script | 3.8 KB |
| scripts/search_utils.py | script | 4.3 KB |
| scripts/stackexchange_search.py | script | 3.2 KB |
| scripts/wikimedia_pageviews.py | script | 5.9 KB |
scripts/stackexchange_search.py
View on GitHub#!/usr/bin/env python3
"""Search Stack Exchange questions without app keys."""
from __future__ import annotations
import argparse
import html
import re
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
from search_utils import get_client, make_item, make_result, print_json
from _filters import CryptoQueryError, filter_crypto_items, reject_crypto_query
API_URL = "https://api.stackexchange.com/2.3/search/advanced"
def _strip_html(value: str) -> str:
text = re.sub(r"<[^>]+>", " ", value or "")
text = re.sub(r"\s+", " ", text).strip()
return html.unescape(text)
def search(
query: str,
limit: int,
site: str = "stackoverflow",
sort: str = "relevance",
tagged: str | None = None,
) -> list[dict]:
reject_crypto_query(query)
params: dict[str, str | int] = {
"q": query,
"order": "desc",
"sort": sort,
"site": site,
"pagesize": min(max(limit * 2, limit), 100),
"filter": "withbody",
}
if tagged:
reject_crypto_query(tagged)
params["tagged"] = tagged
with get_client() as client:
resp = client.get(API_URL, params=params)
resp.raise_for_status()
data = resp.json()
items = []
for row in data.get("items", []):
item = make_item(
title=html.unescape(row.get("title", "")),
url=row.get("link", ""),
snippet=_strip_html(row.get("body", ""))[:300],
score=row.get("score", 0),
view_count=row.get("view_count", 0),
answer_count=row.get("answer_count", 0),
is_answered=row.get("is_answered", False),
tags=row.get("tags", []),
creation_date=row.get("creation_date"),
last_activity_date=row.get("last_activity_date"),
site=site,
)
if filter_crypto_items([item], fields=("title", "snippet", "url", "tags")):
items.append(item)
if len(items) >= limit:
break
return items
def main() -> None:
parser = argparse.ArgumentParser(description="搜索 Stack Exchange 问答(免费、免 API key)")
parser.add_argument("query", help="搜索关键词;加密货币/区块链/Web3 相关查询会被拒绝")
parser.add_argument("--limit", "-n", type=int, default=10, help="返回结果数量(默认 10)")
parser.add_argument("--site", default="stackoverflow", help="站点 api_site_parameter,默认 stackoverflow")
parser.add_argument("--sort", default="relevance", choices=["relevance", "votes", "creation", "activity"], help="排序方式")
parser.add_argument("--tagged", help="标签过滤,多个用分号分隔")
args = parser.parse_args()
try:
items = search(args.query, args.limit, args.site, args.sort, args.tagged)
print_json(make_result(True, args.query, "stackexchange", items))
except CryptoQueryError as exc:
print_json(make_result(False, args.query, "stackexchange", [], str(exc)))
sys.exit(2)
except Exception as exc:
print_json(make_result(False, args.query, "stackexchange", [], str(exc)))
sys.exit(1)
if __name__ == "__main__":
main()
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |