Package: knewkarma
ARedditData Analysis Toolkit.Feature OverviewKnew Karma CLI/GUIKnew Karma can get the following Reddit data from individual targets:User:Profile,Posts,CommentsSubreddit:Profile,PostsIt can also get posts from various sources, such as:Searching: Allows getting posts that match the user-provided query from all over RedditReddit Front-Page: Allows getting posts from the Reddit Front-PageListing: Allows getting posts from a user-specified Reddit ListingBonus FeaturesFully Async (both in the CLI and GUI)Dark Mode(GUI Automatic/Manual)Write data to files(JSON/CSV)Knew Karma Python LibraryCode ExamplesGet User DataimportasyncioimportaiohttpfromknewkarmaimportRedditUser# Define an asynchronous function to fetch Userasyncdefasync_user(username:str):# Initialize RedditUser with the specified usernameuser=RedditUser(username=username)# Establish an asynchronous HTTP sessionasyncwithaiohttp.ClientSession()assession:# Fetch user's profileprofile=awaituser.profile(session=session)# timeframes: ["hour", "day", "month", "year"]. Leave parameter unspecified to get from all timeframes.# sorting: ["controversial", "new", "top", "best", "hot", "rising"]. Leave parameter unspecified to get from all sort criteria.# Fetch user's postsposts=awaituser.posts(limit=200,sort="top",timeframe="year",session=session)# Fetch user's commentscomments=awaituser.comments(limit=200,sort="top",timeframe="year",session=session)print(profile)print(posts)print(comments)asyncio.run(async_user(username="automoderator"))Get Subreddit DataimportasyncioimportaiohttpfromknewkarmaimportRedditSubasyncdefasync_subreddit(subreddit_name:str):# Initialize RedditSub with the specified subredditsubreddit=RedditSub(subreddit=subreddit_name)# Create an asynchronous HTTP sessionasyncwithaiohttp.ClientSession()assession:# Fetch subreddit's profileprofile=awaitsubreddit.profile(session=session)# Fetch subreddit's posts# timeframes: ["hour", "day", "month", "year"]. Leave parameter unspecified to get from all timeframes.# sorting: ["controversial", "new", "top", "best", "hot", "rising"]. Leave parameter unspecified to get from all sort criteria.posts=awaitsubreddit.posts(limit=100,sort="top",timeframe="month",session=session)print(profile)print(posts)asyncio.run(async_subreddit(subreddit_name="MachineLearning"))Get PostsimportasyncioimportaiohttpfromknewkarmaimportRedditPostsasyncdefasync_posts():# Initialize RedditPostsposts=RedditPosts()# Create an asynchronous HTTP sessionasyncwithaiohttp.ClientSession()assession:# timeframes: ["hour", "day", "month", "year"]. Leave parameter unspecified to get from all timeframes.# sorting: ["controversial", "new", "top", "best", "hot", "rising"]. Leave parameter unspecified to get from all sort criteria.# Fetch front page postsfront_page_posts=awaitposts.front_page(limit=50,sort="top",timeframe="hour",session=session)# Fetch posts from a specified listing ('best')listing_posts=awaitposts.listing(listings_name="best",limit=50,sort="best",timeframe="month",session=session)# Fetch posts that match the specified search query 'covid-19'search_results=awaitposts.search(query="covid-19",limit=300,session=session)print(front_page_posts)print(listing_posts)print(search_results)asyncio.run(async_posts())DocumentationRefer to the Wikifor Installation, Usage and Uninstallation
instructions.