filmov
tv
How-to Use The Reddit API in Python

Показать описание
Learn how to use the Reddit API in Python, including setup, authorization, and pulling data from subreddits.
Reddit API docs:
🤖 70% Discount on the NLP With Transformers in Python course:
📙 Medium article:
📖 Free link:
Extract from article:
"Reddit is a huge ecosystem brimming with data that is readily available at our very fingertips. As a data-minded person, I wanted to take advantage of this and perform some analysis using this vast repository of open-source data.
Initially, it turned out that getting to grip with Reddit’s API wasn’t as clear-cut as expected — despite being a straightforward process; it can be a little confusing at first.
So, after figuring everything out, I wrote this article — which I hope will help a few of you to get familiar with using the Reddit API in Python. We will cover:
Getting Access
Making Requests
- Reading the Data
- Streaming New Posts
Parameters
Getting Access
First, we need access. Unlike most popular services, the Reddit API was somewhat difficult to figure out initially. There are several steps:
1. Go to App Preferences and click create another app… at the bottom.
2. Fill out the required details, make sure to select script — and click create app.
3. make a note of the personal use script and secret tokens.
4. Request a temporary OAuth token from Reddit. We need our username and password for this.
5. Add headers=headers to every request. The OAuth token will expire after ~2 hours, and a new one will need to be requested.
"
And so on, check it out if you're interested in reading (rather than watching).
🕹️ Free AI-Powered Code Refactoring with Sourcery:
Reddit API docs:
🤖 70% Discount on the NLP With Transformers in Python course:
📙 Medium article:
📖 Free link:
Extract from article:
"Reddit is a huge ecosystem brimming with data that is readily available at our very fingertips. As a data-minded person, I wanted to take advantage of this and perform some analysis using this vast repository of open-source data.
Initially, it turned out that getting to grip with Reddit’s API wasn’t as clear-cut as expected — despite being a straightforward process; it can be a little confusing at first.
So, after figuring everything out, I wrote this article — which I hope will help a few of you to get familiar with using the Reddit API in Python. We will cover:
Getting Access
Making Requests
- Reading the Data
- Streaming New Posts
Parameters
Getting Access
First, we need access. Unlike most popular services, the Reddit API was somewhat difficult to figure out initially. There are several steps:
1. Go to App Preferences and click create another app… at the bottom.
2. Fill out the required details, make sure to select script — and click create app.
3. make a note of the personal use script and secret tokens.
4. Request a temporary OAuth token from Reddit. We need our username and password for this.
5. Add headers=headers to every request. The OAuth token will expire after ~2 hours, and a new one will need to be requested.
"
And so on, check it out if you're interested in reading (rather than watching).
🕹️ Free AI-Powered Code Refactoring with Sourcery:
Комментарии