For AI agents: a documentation index is available at /llms.txt
Skip to main content

Scrape Reddit Posts

Extract post titles, scores, comment counts, and links from any subreddit.

Prerequisites

Steps

Reddit's feed is fully JavaScript-rendered and detects automated requests, so a plain HTTP fetch returns no useful data. If you only need basic post data, Reddit's JSON API (reddit.com/r/{subreddit}.json) is simpler and doesn't require a browser. Use the browser approach when you need data the API doesn't expose, want to avoid API rate limits, or are scraping user profiles and comment threads.

The examples below target r/programming and route through stealth mode and a residential proxy to bypass Reddit's fingerprinting and rate limiting.

Selector stability

Reddit updates its markup periodically. If shreddit-post stops returning results or attributes come back null, inspect the live page with browser DevTools to find the current element and attribute names.

Send the BQL mutation over HTTP to the stealth endpoint. No browser library or BQL IDE required.

View Full Code on GitHub

1. Send the request

curl -X POST \
"https://production-sfo.browserless.io/stealth/bql?token=YOUR_API_TOKEN_HERE&proxy=residential&proxyCountry=us" \
-H "Content-Type: application/json" \
-d '{
"query": "mutation ScrapeRedditPosts { goto(url: \"https://www.reddit.com/r/programming/\", waitUntil: networkIdle) { status } waitForSelector(selector: \"shreddit-post\", timeout: 15000) { time } posts: mapSelector(selector: \"shreddit-post\") { title: attribute(name: \"post-title\") { value } score: attribute(name: \"score\") { value } commentCount: attribute(name: \"comment-count\") { value } permalink: attribute(name: \"permalink\") { value } } }",
"variables": {}
}'

2. Check the output

{
"data": {
"goto": { "status": 200 },
"waitForSelector": { "time": 2103 },
"posts": [
{
"title": { "value": "Show HN: I built a static site generator in Go" },
"score": { "value": "1847" },
"commentCount": { "value": "143" },
"permalink": { "value": "/r/programming/comments/abc123/show_hn_i_built_a_static_site_generator" }
},
{
"title": { "value": "Why I still use Vim in 2025" },
"score": { "value": "923" },
"commentCount": { "value": "312" },
"permalink": { "value": "/r/programming/comments/def456/why_i_still_use_vim_in_2025" }
}
]
}
}

Next steps