DEV Community

Cover image for dontClickTheMail🚫📰🗞️: Clean Up Your Reddit Feed - Scrape Daily Mail articles to read without clicking the link!
Simon Whelan
Simon Whelan

Posted on

dontClickTheMail🚫📰🗞️: Clean Up Your Reddit Feed - Scrape Daily Mail articles to read without clicking the link!

Are you tired of seeing Daily Mail links polluting your Reddit feeds? Look no further! With dontClickTheMail, you can easily filter out Daily Mail articles and still be able to read their content without clicking the link to the website!

This Python script uses the popular PRAW library, which allows access to the Reddit API, as well as BeautifulSoup and requests to scrape the content of Daily Mail articles. Once the script finds a Daily Mail article in a specified subreddit, it will scrape the article's content and post it as a comment, so you and other users can read the article without giving the Daily Mail any clicks or ad revenue.

To get started, you'll need to have a Reddit account and a Reddit API client ID and client secret. You can obtain these by following the instructions here.

Once you have your client ID and secret, you'll need to create a praw.ini file in your working directory. This file should contain the configuration details that PRAW uses to connect to the Reddit API, such as your client ID and client secret. It's recommended to use a praw.ini file to store these sensitive details as it's more secure and easier to manage. In addition to this, you should also replace "yourusernamehere" with your Reddit username in the script.

Your praw.ini should look something like this:

example of praw.ini file

The script also requires the following Python modules:

BeautifulSoup
requests

You can install these dependencies by running the following command:

pip install praw bs4 requests
Enter fullscreen mode Exit fullscreen mode

Once you have everything set up, you can run the script and specify which subreddits you'd like to scan for Daily Mail articles.

code to choose subreddits

The script will scan the 100 newest posts in the specified subreddits, and post the article's content as a comment if it finds a Daily Mail article that the bot hasn't already commented on.

code for post limit

Screenshots!

screenshot1

screenshot2

screenshot3

So, if you're tired of seeing Daily Mail articles in your Reddit feeds, give the "dontClickTheMail" script a try and enjoy a cleaner and more personalized browsing experience!

Thanks for reading, and happy coding! 👋

Please note that this script is for educational purposes only and should be used responsibly and in accordance with Reddit's API rules. Do not use it to spam Reddit, or to post comments that violate Reddit's terms of service. The author of this program is not responsible for any consequences that may result from the use of this program.

Top comments (0)