How to Create a Reddit Bot to Detect Spam with Python Reddit API Wrapper (PRAW), Tutorial Part 4

19.1K views
•
January 19, 2018
by
sentdex
YouTube video player
How to Create a Reddit Bot to Detect Spam with Python Reddit API Wrapper (PRAW), Tutorial Part 4

TL;DR

Create a Reddit bot with Python Reddit API Wrapper (PRAW) by configuring a script app, loading its credentials, finding posts that mention Udemy, and reviewing each poster’s submission history before labeling the account as spam. The tutorial explains why one matching link is insufficient and shows how the bot warns users on suspicious threads. Read on for the setup, detection logic, and planned improvements.

Transcript

what's going on everybody and welcome to a creating a reddit bot tutorial in Python so what we're gonna be doing specifically is creating a reddit bot that goes through and detects reddit spam and affiliate links specifically in this case to udemy but we could very easily modify this to detect quite a bit of spam so over like the last year I've not... Read More

Key Insights

  • "over like the last year I've noticed this is crazy sharp incline in the amount of just udemy affiliate link spam coming in to Reddit" (0:21)
  • "make an account go to your account preferences app create the app make sure it's a script app that's about it really fill out the form" (2:21)
  • "just because someone's posting a link that does go to udemy it doesn't necessarily mean that they're a spammer" (3:29)
  • "in my case we're just looking for the term udemy but in time I plan to expand that out" (5:00)

Explore YouTube Video Summarizer or Get YouTube Transcript Extractor

Questions & Answers

Q: How do you create a Reddit bot to detect spam with Python Reddit API Wrapper (PRAW)?

Create a Reddit account and a script app, then obtain the client ID, secret, password, user agent, and username. Load those credentials into the Python script, create the Reddit object, find relevant posts, and inspect each poster’s submission history before treating the account as spam.

Q: What kind of Reddit spam does the bot detect?

The bot initially looks for Udemy affiliate-link spam. The creator says it could be modified to detect other types of spam and plans to expand beyond searching only for the term "udemy."

Q: Why was the Reddit spam bot created?

The creator had noticed a sharp increase in Udemy affiliate-link spam over the last year. The immediate motivation came after finding a pirated copy of one of the creator’s courses being spammed on Reddit.

Q: How were Udemy affiliate links being disguised on Reddit?

Spammers sometimes linked to a Twitter or Medium post that led to Udemy. They also used tracker sites that redirected users to Udemy, although the creator observed that some posts had begun linking directly to those tracker sites.

Q: What credentials are required for the Reddit bot?

The tutorial lists a client ID, secret, password, user agent, and username. These values come from creating a Reddit script app through the account preferences and app setup process.

Q: How does the bot decide whether a Reddit user is a spammer?

The bot does not assume that one link leading to Udemy proves the user is a spammer. It opens the username’s page and checks whether all, some, or few of the account’s posts contain Udemy-related content.

Q: What does the bot do after finding suspected spam?

The bot goes to relevant threads and posts a message about the suspected behavior. One example message reports that six of a user’s 33 submissions appear to be Udemy affiliate links.

Q: Can the Reddit bot detect spam that does not contain the word Udemy?

The demonstrated version searches for the term "udemy," so its initial detection is limited. The creator plans to add better words and other ways to match courses because spammers could remove that term once they understand the rule.

Summary & Key Takeaways

  • The creator noticed a rise in udemy affiliate link spam on Reddit and decided to create a bot to detect and remove it.

  • The bot identifies potential spammers by analyzing their post history and checking for certain keywords.

  • Once identified, the bot posts a message on their thread notifying them of their spammy behavior.


Read in Other Languages (beta)

Share This Summary 📚

Explore More Summaries from sentdex 📚