import { BaseExtractor, ExtractorOptions } from './_base'; import { ExtractorResult } from '../types/extractors'; export declare class RedditExtractor extends BaseExtractor { private shredditPost; private isOldReddit; constructor(document: Document, url: string, schemaOrgData?: any, options?: ExtractorOptions); canExtract(): boolean; canExtractAsync(): boolean; prefersAsync(): boolean; private isCommentsPage; extractAsync(): Promise; private tryOldReddit; /** * Reddit's Atom feed is the only unauthenticated source still serving post * content. It is flat and score-less, so the output is thinner than the * old.reddit DOM, but it is the difference between a post and an error. */ private extractFromFeed; /** * Fetch through a short-lived cache. * * A single user-facing parse reaches this extractor several times: the CLI * and the Worker both reparse the page when the first pass yields nothing, * and parseAsync() tries a preferred and a general finder. Reddit throttles * the feed to roughly one request per half-minute, so without this the * retries guarantee the 429 they are retrying against. * * The cache is keyed by URL alone, so it is bypassed when the caller * supplies its own fetch — otherwise an authenticated response and an * anonymous one could be served to each other. */ private request; private send; private parseDocument; private extractFeed; private parseFeedEntry; /** * Feed entry bodies are HTML escaped into the XML and wrap the real content * in the same `div.md` the old.reddit DOM uses, so unwrap to match. */ private feedContentHtml; extract(): ExtractorResult; /** * Every source — the rendered DOM, old.reddit.com and the feed — differs * only in where the title, author and body come from, so they share one * result shape. */ private buildResult; private extractOldReddit; private getPostContent; private createContentHtml; private extractComments; private getPostId; private getSubreddit; private getPostAuthor; private createDescription; private collectOldRedditComments; private processComments; }