Documentation
¶
Overview ¶
Package parser implements the w_popularity tbank-pulse adapter.
T-Bank Pulse (Тинькофф Инвестиции "Пульс") is a social feed for retail investors on tbank.ru. There is no documented public API for the social feed, but the SSR-rendered profile page embeds JSON payloads in <script type="application/json"> tags. We fetch the page HTML and walk those payloads to extract follower counts, post counts and the recent feed.
Strategy:
primary: HTTP GET of https://www.tbank.ru/invest/social/profile/<handle>/
and parse embedded JSON. Two known shapes:
1. Next.js classic — <script id="__NEXT_DATA__"> with full
page props.
2. T-Bank "tramvai" framework — <script id="__TRAMVAI_CHILD_STATE__">
where the profile lives at
.social-profile@<hash>.stores.investSocialProfiles.<handle>.
We scan all <script type="application/json"> tags and pick the
deepest object containing follower-like + post-like fields.
fallback: camoufox (browser automation). TODO: not wired yet — see
Config.CamoufoxURL. The post feed appears to be loaded client-side
via authenticated XHRs, so getting post-level engagement on
production likely requires camoufox.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// UserAgent overrides the outgoing User-Agent header.
UserAgent string
// HTTPClient lets tests inject a custom transport. When nil a default
// client with HTTPTimeout is used.
HTTPClient *http.Client
// HTTPTimeout caps every outbound call. Default 20s.
HTTPTimeout time.Duration
// BaseURL overrides the production tbank.ru host. Tests use this to point
// at an httptest.Server. Trailing slash is stripped.
BaseURL string
// CamoufoxURL, when set, will be used to drive a remote camoufox browser
// for scraping. NOT wired in this revision — see package docs.
CamoufoxURL string
}
Config controls runtime behaviour.
type TBankPulseParser ¶
type TBankPulseParser struct {
// contains filtered or unexported fields
}
func (*TBankPulseParser) FetchChannel ¶
func (p *TBankPulseParser) FetchChannel(ctx context.Context, handle string) (shared.ChannelSnapshot, error)
FetchChannel returns one snapshot for the Pulse profile identified by handle.
func (*TBankPulseParser) FetchRecentPosts ¶
func (p *TBankPulseParser) FetchRecentPosts(ctx context.Context, handle string, since time.Time) ([]shared.PostSnapshot, error)
FetchRecentPosts returns posts in the profile's recent feed whose published time is at or after `since`. Newest-first.
func (*TBankPulseParser) Platform ¶
func (p *TBankPulseParser) Platform() shared.Platform