Exports all accessible reddit comments for an account using pushshift
Exports all accessible reddit comments for an account using pushshift.
To install with pip, run:
pip install pushshift_comment_export
Is accessible as the script
ps_comments, or by using
python3 -m pushshift_comment_export.
Reddit (supposedly) only indexes the last 1000 items per query, so there are lots of comments that I don't have access to using the official reddit API (I run
rexport periodically to pick up any new data.)
This downloads all the comments that pushshift has, which is typically more than the 1000 query limit. This is only really meant to be used once per account, to access old data that I don't have access to.
For context see the comments here. From what I've read on random reddit threads, doesn't seem reddit's GDPR process is worked out yet either, so not sure if that sending their legal team a request would work out well.
Complies to the rate limit described here
$ ps_comments <reddit_username> --to-file ./data.json ..... [D 200903 19:51:49 __init__:43] Have 4700, now searching for comments before 2015-10-07 23:32:03... [D 200903 19:51:49 __init__:17] Requesting https://api.pushshift.io/reddit/comment/search?author=username&limit=100&sort_type=created_utc&sort=desc&before=1444260723... [D 200903 19:51:52 __init__:43] Have 4800, now searching for comments before 2015-09-22 13:55:00... [D 200903 19:51:52 __init__:17] Requesting https://api.pushshift.io/reddit/comment/search?author=username&limit=100&sort_type=created_utc&sort=desc&before=1442930100... [D 200903 19:51:57 __init__:43] Have 4860, now searching for comments before 2014-08-28 07:10:14... [D 200903 19:51:57 __init__:17] Requesting https://api.pushshift.io/reddit/comment/search?author=username&limit=100&sort_type=created_utc&sort=desc&before=1409209814... [I 200903 19:52:01 __init__:64] Done! writing 4860 comments to file ./data.json
pushshift doesn't require authentication, if you want to preview what this looks like, just go to https://api.pushshift.io/reddit/comment/search?author=
(Personal HPI Usage)
I merge this with the output of the
rexport NamedTuple in
raw property on the pushshift/rexport values have different values, but I've standardized the
@property values across both the
<function my.reddit.comments() -> Iterator[Union[rexport.dal.Comment, pushshift_comment_export.dal.PComment]]>
In case it wasn't already clear, pushshift provides me with comment data going further back than 1000 entires, which reddits API can't do. I only run
ps_comments once, but I run
rexport every couple weeks to save any new comments/saves.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size pushshift_comment_export-0.1.2.tar.gz (5.8 kB)||File type Source||Python version None||Upload date||Hashes View|
|Filename, size pushshift_comment_export-0.1.2-py3-none-any.whl (6.5 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
Hashes for pushshift_comment_export-0.1.2.tar.gz
Hashes for pushshift_comment_export-0.1.2-py3-none-any.whl