reddit-research-scrape
GitHub从Reddit抓取帖子数据并生成病毒式视频脚本。通过JSON API获取准确指标,调用后端API生成西班牙语脚本,输出结构化Markdown和索引文件。
Trigger Scenarios
Install
npx skills add leamsigc/ShortsGenerator --skill reddit-research-scrape -g -y
SKILL.md
Frontmatter
{
"name": "reddit-research-scrape",
"version": "3.0.0",
"description": "Scrape state — runs the Reddit JSON API scraper for correct data (upvotes,\ncomment counts, full comment trees, exact selftext), then generates a viral\nvideo script per post from the post content + top comments via the backend\nAPI. Saves structured markdown files + index.json.\n",
"allowed-tools": [
"Bash",
"Read",
"Write",
"ChromeDevTools"
]
}
Reddit Research — Scrape State (v3)
Scrapes top posts from a subreddit with correct upvotes/comment counts using Reddit's JSON API, then generates a viral video script per post.
Before running
Ensure the Flask backend is running on port 8080 (for script generation): curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/api/models
Run
node "$CLAUDE_SKILL_ROOT/scripts/scrape.js" <subreddit> [limit] [sort] [lang] [--session <id>] [--data-root <path>]
# fallback: node ./skills/reddit-research/scripts/scrape.js <subreddit> ...
Defaults: limit=10, sort=hot, lang=es (Spanish).
What the script does
- Fetches the subreddit listing JSON:
https://www.reddit.com/r/<sub>/<sort>.json?limit=<n> - For each post, fetches
<permalink>.jsonfor correct data:- Accurate upvotes (not the HTML bug showing
1) - Accurate comment counts, full comment trees with correct scores
- Exact
selftext, video URL (media.reddit_video.fallback_url), linked URL
- Accurate upvotes (not the HTML bug showing
- Extracts the top 10 comments (depth ≤ 2)
- Generates a viral video script via the backend API (title + content + top comments), ~30-60s
- Writes
.reddit-research/<YYYY-MM-DD_HHMMSS>/<post-slug>.md(dated session) with:# Title, author, upvotes, comments, source, scraped date## Content,## Viral Video Script (Spanish),## Videos,## Sourced Videos(placeholder),## Top Comments
- Writes
index.json(posts[]with index/title/file/url/upvotes/comments)
Manual fallback (Chrome DevTools CLI)
If the JSON API is blocked, scrape the listing page manually:
chrome-devtools navigate_page --url "https://www.reddit.com/r/<subreddit>/<sort>/"— scroll to load more posts- Extract post URLs from
a[href*="/comments/"] - Fetch each post's data via
fetch("<post_url>.json")inevaluate_script - Write the same markdown + index.json structure
Key points
| Issue | HTML scrape | JSON API |
|---|---|---|
| Upvotes | Often 1 |
Correct count |
| Comment count | Missing | Correct count |
| Comments | Author/score missing | All fields present |
Errors
If a post's JSON API errors (deleted/private/NSFW), log it, skip to the next post, and note the failure in index.json.
Version History
- 7b83166 Current 2026-08-29 02:31


