dontClickTheMail🚫📰🗞️: Clean Up Your Reddit Feed - Scrape Daily Mail articles to read without clicking the link!
Tags: python, api, webdev, webscraping
Published: 2023-01-16 18:38:08

Are you tired of seeing Daily Mail links polluting your Reddit feeds? Look no further! With [dontClickTheMail](https://github.com/siwhelan/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](https://praw.readthedocs.io/en/stable/) 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](https://praw.readthedocs.io/en/stable/getting_started/quick_start.html#). 

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/txtatn4syca09eabagjs.png)

The script also requires the following Python modules:

[BeautifulSoup](https://pypi.org/project/beautifulsoup4/)
[requests](https://pypi.org/project/requests/)

You can install these dependencies by running the following command:

    pip install praw bs4 requests

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/srbqrs092n4h79798oku.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hz1wp67i79s23611iwt1.png)

Screenshots! 

![screenshot1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xyj4jt7jpgl66qum71mr.jpeg)


![screenshot2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qlwq4dp7db48hsmkwebf.jpeg)


![screenshot3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/snzkmbuv0kzmuj9619os.jpeg)

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](https://www.reddit.com/wiki/api/). 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._