Documentation
¶
Overview ¶
Package parser implements the w_popularity Reddit adapter.
Strategy: Reddit's public JSON API at https://www.reddit.com/user/<handle>/about.json (and /submitted.json) exposes karma + recent submissions without auth.
Caveats:
- Reddit requires a non-default User-Agent or it 429s aggressively. The default UA used here identifies as w_popularity/<host> and is compliant with Reddit's API rules ("unique and descriptive UA").
- "Followers" doesn't map 1:1 onto a Reddit user. We use Reddit's own personal-subreddit subscriber count (u/<user>) when available (`subreddit.subscribers`); else total_karma as a proxy.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
HTTPClient *http.Client
HTTPTimeout time.Duration
UserAgent string
// BaseURL overrides https://www.reddit.com. Test hook.
BaseURL string
// BearerToken is an optional Reddit OAuth bearer token. When set, the
// parser routes to oauth.reddit.com instead of www.reddit.com (which
// bumps the rate limit from 10 req/min anon to 100 req/min authed).
// Not required for read-only scraping of public profiles.
BearerToken string
}
Config controls runtime behaviour.
type RedditParser ¶
type RedditParser struct {
// contains filtered or unexported fields
}
func New ¶
func New(cfg Config) *RedditParser
func (*RedditParser) FetchChannel ¶
func (p *RedditParser) FetchChannel(ctx context.Context, handle string) (shared.ChannelSnapshot, error)
FetchChannel returns one snapshot for the Reddit user `handle`. Followers = personal-subreddit subscribers if exposed, else total karma.
func (*RedditParser) FetchRecentPosts ¶
func (p *RedditParser) FetchRecentPosts(ctx context.Context, handle string, since time.Time) ([]shared.PostSnapshot, error)
FetchRecentPosts pulls /user/<handle>/submitted.json (last 50 submissions).
func (*RedditParser) Platform ¶
func (p *RedditParser) Platform() shared.Platform
Click to show internal directories.
Click to hide internal directories.