A Reddit Data Analysis Toolkit.
Project description
A Reddit Data Analysis Toolkit.
Feature Overview
Knew Karma CLI/GUI
- Knew Karma can get the following Reddit data from individual targets:
- User: Profile, Posts, Comments
- Subreddit: Profile, Posts
- It can also get posts from various sources, such as:
- Searching: Allows getting posts that match the user-provided query from all over Reddit
- Reddit Front-Page: Allows getting posts from the Reddit Front-Page
- Listing: Allows getting posts from a user-specified Reddit Listing
- Bonus Features
- Fully Async (both in the CLI and GUI)
- Dark Mode (GUI Automatic/Manual)
- Write data to files (JSON/CSV)
Knew Karma Python Library
Code Examples
Get User Data
import asyncio
import aiohttp
from knewkarma import RedditUser
# Define an asynchronous function to fetch User
async def async_user(username: str, data_limit: int, data_sort: str):
# Initialize a RedditUser object with the specified username, data limit, and sorting criteria
user = RedditUser(username=username, data_limit=data_limit, data_sort=data_sort)
# Establish an asynchronous HTTP session
async with aiohttp.ClientSession() as session:
# Fetch user's profile
profile = await user.profile(session=session)
# Fetch user's posts
posts = await user.posts(session=session)
# Fetch user's comments
comments = await user.comments(session=session)
print(profile)
print(posts)
print(comments)
# Run the asynchronous function with a specified username, data limit, and sorting parameter
asyncio.run(async_user(username="automoderator", data_limit=100, data_sort="all"))
Get Subreddit Data
import asyncio
import aiohttp
from knewkarma import RedditSub
# Define an asynchronous function to fetch Subreddit data
async def async_subreddit(subreddit_name: str, data_limit: int, data_sort: str):
# Initialize a RedditSub object with the specified subreddit, data limit, and sorting criteria
subreddit = RedditSub(
subreddit=subreddit_name, data_limit=data_limit, data_sort=data_sort
)
# Create an asynchronous HTTP session
async with aiohttp.ClientSession() as session:
# Fetch subreddit's profile
profile = await subreddit.profile(session=session)
# Fetch subreddit's posts
posts = await subreddit.posts(session=session)
print(profile)
print(posts)
# Run the asynchronous function with specified subreddit name, data limit, and sorting criteria
asyncio.run(
async_subreddit(subreddit_name="MachineLearning", data_limit=100, data_sort="top")
)
Get Posts
import asyncio
import aiohttp
from knewkarma import RedditPosts
# Define an asynchronous function to fetch Reddit posts
async def async_posts(limit: int, sort: str):
# Initialize RedditPosts with the specified limit and sorting criteria
posts = RedditPosts(limit=limit, sort=sort)
# Create an asynchronous HTTP session
async with aiohttp.ClientSession() as session:
# Fetch front page posts
front_page_posts = await posts.front_page(session=session)
# Fetch posts from a specified listing ('best')
listing_posts = await posts.listing(listings_name="best", session=session)
# Fetch posts that match the specified search query 'covid-19'
search_results = await posts.search(query="covid-19", session=session)
print(front_page_posts)
print(listing_posts)
print(search_results)
# Run the asynchronous function with a specified limit and sorting parameter
asyncio.run(async_posts(limit=100, sort="all"))
Documentation
Refer to the Wiki for Installation, Usage and Uninstallation instructions.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
knewkarma-3.0.0.0.tar.gz
(13.3 kB
view hashes)
Built Distribution
Close
Hashes for knewkarma-3.0.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81d530d3b959cca0ea8b66a6c813ed8f0e8fbfa302949b45898951e911a417bd |
|
MD5 | cb4316c2a96c007469a5fcf48abef87b |
|
BLAKE2b-256 | f4b4112e7593d6f18d168e9371069fd1924203bd8dc119fd9909216bba33f548 |