RedditPostsLoader#
- class langchain_community.document_loaders.reddit.RedditPostsLoader(client_id: str, client_secret: str, user_agent: str, search_queries: Sequence[str], mode: str, categories: Sequence[str] = ['new'], number_posts: int | None = 10)[source]#
Load Reddit posts.
Read posts on a subreddit. First, you need to go to https://www.reddit.com/prefs/apps/ and create your application
- Initialize with client_id, client_secret, user_agent, search_queries, mode,
categories, number_posts.
Example: https://www.reddit.com/r/learnpython/
- Parameters:
client_id (str) β Reddit client id.
client_secret (str) β Reddit client secret.
user_agent (str) β Reddit user agent.
search_queries (Sequence[str]) β The search queries.
mode (str) β The mode.
categories (Sequence[str]) β The categories. Default: [βnewβ]
number_posts (Optional[int]) β The number of posts. Default: 10
Methods
__init__
(client_id,Β client_secret,Β ...[,Β ...])Initialize with client_id, client_secret, user_agent, search_queries, mode,
A lazy loader for Documents.
aload
()Load data into Document objects.
A lazy loader for Documents.
load
()Load reddits.
load_and_split
([text_splitter])Load Documents and split into chunks.
- __init__(client_id: str, client_secret: str, user_agent: str, search_queries: Sequence[str], mode: str, categories: Sequence[str] = ['new'], number_posts: int | None = 10)[source]#
- Initialize with client_id, client_secret, user_agent, search_queries, mode,
categories, number_posts.
Example: https://www.reddit.com/r/learnpython/
- Parameters:
client_id (str) β Reddit client id.
client_secret (str) β Reddit client secret.
user_agent (str) β Reddit user agent.
search_queries (Sequence[str]) β The search queries.
mode (str) β The mode.
categories (Sequence[str]) β The categories. Default: [βnewβ]
number_posts (int | None) β The number of posts. Default: 10
- async alazy_load() AsyncIterator[Document] #
A lazy loader for Documents.
- Return type:
AsyncIterator[Document]
- load_and_split(text_splitter: TextSplitter | None = None) list[Document] #
Load Documents and split into chunks. Chunks are returned as Documents.
Do not override this method. It should be considered to be deprecated!
- Parameters:
text_splitter (Optional[TextSplitter]) β TextSplitter instance to use for splitting documents. Defaults to RecursiveCharacterTextSplitter.
- Returns:
List of Documents.
- Return type:
list[Document]
Examples using RedditPostsLoader