Skip to content

Commit

Permalink
Merge pull request #63 from bellingcat/dev
Browse files Browse the repository at this point in the history
dev -> 3.5.0.0
  • Loading branch information
rly0nheart committed Dec 22, 2023
2 parents 60471fc + cacb7c3 commit 70bc952
Show file tree
Hide file tree
Showing 11 changed files with 371 additions and 269 deletions.
6 changes: 3 additions & 3 deletions Knew Karma GUI/KnewKarma/KnewKarma.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
<PackageProjectUrl>https://github.com/bellingcat/knewkarma</PackageProjectUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/bellingcat/knewkarma</RepositoryUrl>
<AssemblyVersion>3.4.0.0</AssemblyVersion>
<FileVersion>3.4.0.0</FileVersion>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<FileVersion>3.5.0.0</FileVersion>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<Version>3.4.0</Version>
<Version>3.5.0</Version>
<PackageTags>reddit;scraper;reddit-scraper;osint;reddit-data</PackageTags>
<PackageReleaseNotes></PackageReleaseNotes>
<AnalysisLevel>6.0-recommended</AnalysisLevel>
Expand Down
6 changes: 3 additions & 3 deletions Knew Karma GUI/KnewKarmaSetup/KnewKarmaSetup.vdproj
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,15 @@
{
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:Knew Karma"
"ProductCode" = "8:{54746087-7636-4C00-845D-253E0D22CBA6}"
"PackageCode" = "8:{64395976-B1A2-4CBC-95D0-0AC31AA608D1}"
"ProductCode" = "8:{C7B6617B-86DB-4813-833F-8CDF88EC9A9E}"
"PackageCode" = "8:{9CCEBCAF-AF8F-4CAC-AC25-3EEED66DE5B9}"
"UpgradeCode" = "8:{9B03AD0F-0C14-4075-AB75-01CD38A594B4}"
"AspNetVersion" = "8:2.0.50727.0"
"RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:FALSE"
"ProductVersion" = "8:3.4.0"
"ProductVersion" = "8:3.5.0"
"Manufacturer" = "8:Richard Mwewa"
"ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:https://github.com/bellingcat/knewkarma/wiki"
Expand Down
64 changes: 33 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
![knewkarma](https://github.com/bellingcat/knewkarma/assets/74001397/45262d9d-6633-418d-9ace-7c3c88b5ca36)

![knewkarma-cli](https://github.com/bellingcat/knewkarma/assets/74001397/77e603a3-6830-464c-a7db-da8a724bde2d)

A **Reddit** Data Analysis Toolkit.

Expand Down Expand Up @@ -36,30 +35,32 @@ from knewkarma import RedditUser


# Define an asynchronous function to fetch User
async def async_user(username: str, data_timeframe: str, data_limit: int, data_sort: str):
# Initialize a RedditUser object with the specified username, data timeframe, limit, and sorting criteria
user = RedditUser(username=username, data_timeframe=data_timeframe, data_limit=data_limit, data_sort=data_sort)
async def async_user(username: str):
# Initialize RedditUser with the specified username
user = RedditUser(username=username)

# Establish an asynchronous HTTP session
async with aiohttp.ClientSession() as session:
# Fetch user's profile
profile = await user.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 posts
posts = await user.posts(session=session)
posts = await user.posts(limit=200, sort="top", timeframe="year",
session=session)

# Fetch user's comments
comments = await user.comments(session=session)
comments = await user.comments(limit=200, sort="top", timeframe="year",
session=session)

print(profile)
print(posts)
print(comments)


# Run the asynchronous function with a specified username, data limit, and sorting parameter
# timeframes: ["all", "hour", "day", "month", "year"]
# sorting: ["all", "controversial", "new", "top", "best", "hot", "rising"]
asyncio.run(async_user(username="automoderator", data_timeframe="year", data_limit=100, data_sort="all"))
asyncio.run(async_user(username="automoderator"))
```

### Get Subreddit Data
Expand All @@ -70,29 +71,27 @@ import aiohttp
from knewkarma import RedditSub


async def async_subreddit(subreddit_name: str, data_timeframe: str, data_limit: int, data_sort: str):
# Initialize a RedditSub object with the specified subreddit, data timeframe, limit, and sorting criteria
async def async_subreddit(subreddit_name: str):
# Initialize RedditSub with the specified subreddit
subreddit = RedditSub(
subreddit=subreddit_name, data_timeframe=data_timeframe, data_limit=data_limit, data_sort=data_sort
)
subreddit=subreddit_name)

# 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)
# 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 = await subreddit.posts(limit=100, sort="top", timeframe="month", session=session)

print(profile)
print(posts)


# Run the asynchronous function with specified subreddit name, data limit, and sorting criteria
# timeframes: ["all", "hour", "day", "month", "year"]
# sorting: ["all", "controversial", "new", "top", "best", "hot", "rising"]
asyncio.run(
async_subreddit(subreddit_name="MachineLearning", data_timeframe="year", data_limit=100, data_sort="top")
async_subreddit(subreddit_name="MachineLearning")
)
````

Expand All @@ -104,28 +103,31 @@ import aiohttp
from knewkarma import RedditPosts


async def async_posts(timeframe: str, limit: int, sort: str):
# Initialize RedditPosts with the specified timeframe, limit and sorting criteria
posts = RedditPosts(timeframe=timeframe, limit=limit, sort=sort)
async def async_posts():
# Initialize RedditPosts
posts = RedditPosts()

# Create an asynchronous HTTP session
async with aiohttp.ClientSession() as 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 front page posts
front_page_posts = await posts.front_page(session=session)
front_page_posts = await posts.front_page(limit=50, sort="top", timeframe="hour", session=session)

# Fetch posts from a specified listing ('best')
listing_posts = await posts.listing(listings_name="best", session=session)
listing_posts = await posts.listing(listings_name="best", limit=50, sort="best", timeframe="month",
session=session)

# Fetch posts that match the specified search query 'covid-19'
search_results = await posts.search(query="covid-19", session=session)
search_results = await posts.search(query="covid-19", limit=300, session=session)

print(front_page_posts)
print(listing_posts)
print(search_results)


# Run the asynchronous function with a specified limit and sorting parameter
# timeframes: ["all", "hour", "day", "month", "year"]
# sorting: ["all", "controversial", "new", "top", "best", "hot", "rising"]
asyncio.run(async_posts(timeframe="year", limit=100, sort="all"))
asyncio.run(async_posts())
```

</details>
Expand All @@ -135,5 +137,5 @@ asyncio.run(async_posts(timeframe="year", limit=100, sort="all"))
*[Refer to the Wiki](https://github.com/bellingcat/knewkarma/wiki) for Installation, Usage and Uninstallation
instructions.*
***
[![me](https://github.com/bellingcat/knewkarma/assets/74001397/efd19c7e-9840-4969-b33c-04087e73e4da)](https://about.me/rly0nheart)
[![me](https://github.com/bellingcat/knewkarma/assets/74001397/efd19c7e-9840-4969-b33c-04087e73e4da)](https://rly0nheart.github.io)

0 comments on commit 70bc952

Please sign in to comment.