Last active
November 18, 2022 19:36
-
-
Save HH0718/22673a8fb065ad8797ff2fc71f3cce2c to your computer and use it in GitHub Desktop.
A reddit PushShift API call to get total user comments.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
def get_author_total_comments(**kwargs): | |
r = requests.get("https://api.pushshift.io/reddit/comment/search/", params=kwargs) | |
data = r.json() | |
return data['metadata']['total_results'] | |
if __name__ == "__main__": | |
total_results = get_author_total_comments(author="UnemployedTechie2021", size=0, metadata=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks.
I saw your other post and here is an effort at me "refactoring" it and providing some feedback.
Notice I took away pandas for the time being as it is a large package.
Simply put, pandas was an expensive package to have when you can get the same results without it.
I'm sure you have use for it in the future, but implement one function/feature at a time as simple as possible. Then use pandas or whatever other packages you need to perform the work you need.