Documentation
¶
Overview ¶
Package parser implements the w_popularity smart-lab.ru adapter.
Strategy:
primary: HTML scrape of https://smart-lab.ru/my/<handle>/ fallback: none — Smart-Lab profile pages are fully public
The profile page exposes follower count ("Читают"), post count ("Записи") and a chronological list of the user's blog posts. Each post block carries id, slug-style URL (/blog/<id>.php), human-readable publish date, view count (e.g. "3.5К") and a comment counter. We extract those fields with a combination of tokenizer + regexp, tolerating layout drift by recording uncertain values in Raw rather than failing the snapshot.
Smart-Lab today serves UTF-8; historic pages used Windows-1251. The HTTP helper sniffs Content-Type and the page's <meta charset> to pick the right decoder via golang.org/x/text/encoding/charmap.
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 string
Credential string
CamoufoxURL string
}
Config controls runtime behaviour.
- HTTPClient: if nil, New() builds one with HTTPTimeout (default 15s).
- HTTPTimeout: only used when HTTPClient is nil.
- UserAgent: defaults to a Chrome-on-macOS string. Smart-Lab serves a stub page to clients that look like default Go.
- BaseURL: defaults to "https://smart-lab.ru". Override for tests.
- Credential / CamoufoxURL: reserved for future use; not consulted today.
type SmartLabParser ¶
type SmartLabParser struct {
// contains filtered or unexported fields
}
SmartLabParser implements shared.Parser for smart-lab.ru.
func (*SmartLabParser) FetchChannel ¶
func (p *SmartLabParser) FetchChannel(ctx context.Context, handle string) (shared.ChannelSnapshot, error)
FetchChannel returns a ChannelSnapshot for the given handle (no leading /).
func (*SmartLabParser) FetchRecentPosts ¶
func (p *SmartLabParser) FetchRecentPosts(ctx context.Context, handle string, since time.Time) ([]shared.PostSnapshot, error)
FetchRecentPosts returns the user's posts from the profile page, newest-first. The public page paginates aggressively; we return what's on the first page and let the caller request more via a tighter `since` window if needed.
func (*SmartLabParser) Platform ¶
func (p *SmartLabParser) Platform() shared.Platform