<p dir="auto">Outside of Steemit I expect a heck of a lot of you are also members of Reddit.
<p dir="auto">Keeping up with your favourite subreddit can be tricky - what if the best submissions came to you, rather than you going and looking?
<h3>Reddit API Wrapper for Python
<p dir="auto">Reddit has a decent API, and there is a Python wrapper called <a href="https://praw.readthedocs.io" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">PRAW (Python Reddit API Wrapper). PRAW is available via pip
<p dir="auto"><code>pip install praw
<h3>API Keys
<p dir="auto">To get started all you need to do is go into your account and set up your new app as a script.
<p dir="auto"><img src="https://images.hive.blog/768x0/https://steemitimages.com/DQmQSNBUbd8PtwhK8JyN8gUmP3m7LU4NqCzjA9VgRSLMim9/Screenshot%20from%202018-05-15%2014-20-52.png" alt="Screenshot from 2018-05-15 14-20-52.png" srcset="https://images.hive.blog/768x0/https://steemitimages.com/DQmQSNBUbd8PtwhK8JyN8gUmP3m7LU4NqCzjA9VgRSLMim9/Screenshot%20from%202018-05-15%2014-20-52.png 1x, https://images.hive.blog/1536x0/https://steemitimages.com/DQmQSNBUbd8PtwhK8JyN8gUmP3m7LU4NqCzjA9VgRSLMim9/Screenshot%20from%202018-05-15%2014-20-52.png 2x" />
<p dir="auto">You will be given your unique API details, that you can then use to gain read access. If you want more than that you will need oAuth and/or your login.
<p dir="auto">From there the code is very simple
<h3>Code
<pre><code>import praw
reddit = praw.Reddit(client_id='',
client_secret='',
user_agent='')
# get top 20 from 3dprinting
for submission in reddit.subreddit('3dprinting').hot(limit=20):
print(submission.title)
print(submission.url)
print()
<p dir="auto"><span><img src="https://images.hive.blog/768x0/https://cdn.discordapp.com/attachments/383256479056134146/446022370608676864/makerhacks.png" srcset="https://images.hive.blog/768x0/https://cdn.discordapp.com/attachments/383256479056134146/446022370608676864/makerhacks.png 1x, https://images.hive.blog/1536x0/https://cdn.discordapp.com/attachments/383256479056134146/446022370608676864/makerhacks.png 2x" />
How to Read Reddit with Python
7 years ago in #python by makerhacks (70)
$42.10
- Past Payouts $42.10
- - Author $33.45
- - Curators $8.64
41 votes
- kingscrown: $18.78
- boatymcboatface: $5.13
- kamikaze: $2.22
- blockops: $2.20
- inceptionally: $2.19
- ipromote: $2.16
- olsm: $2.04
- resiliencia: $1.65
- theshell: $1.50
- howo: $0.82
- drmake: $0.46
- martinphoto: $0.28
- rossco99: $0.27
- makerhacks: $0.25
- libertyranger: $0.24
- olegnator: $0.23
- stephanie-hakel: $0.22
- ilyastarar: $0.20
- theuxyeti: $0.18
- tony10: $0.13
- and 21 more