DEV Community

Cover image for I built a REDDIT BOT which downloads top videos in seconds!
Anas Dew
Anas Dew

Posted on • Edited on

I built a REDDIT BOT which downloads top videos in seconds!

Feeling Board? This SCRIPT can give you a bunch of reddit videos of your interest in SECONDS!. No Account/Signing Needed.

Having a bot is really a cool thing. So let's build one for ourselves. If you keep reading i've a surprise specially for you.

🤖 Introduction to BOT

This bot downloads the most popular videos from a specific subreddit channel. It is written in Python and will require internet access to the function (Ofcourse). It will provide a list of videos in the highest resolution available.

⚙ How does it work?

There're two phases. In the first phase, it will get links to all the top videos from a given subreddit. And in the second phase, it will download videos and save them to your machine. Easy right? Yeah it is.

🧻 The First Phase

Getting the video links of top videos from a given subreddit. On reddit each video element has a class from which we will target that element and get the link.

element = soup.find_all("a", class_="SQnoC3ObvgnGjWt90zD9Z _2INHSNB8V5eaWp4P0rY_mE")

Let's see the whole script of link scraper.

code of web scraper

This function will return all top links of videos as a list.

📺 The Second Phase

It will download the video and save it to your directory.

code of reddit downloader

Now we've two functions, one to get links of videos and another to download a single video by link.

📞 Start.py

The components are done. Now it's time to make them work together by creating a script to make them work for each other. See the final step below.

Can't embed video here. So i've uploaded video to Drive.
Reddit Bot final step

🎁 That's a wrap!

Before you go. I want to tell you that here at Dev.to, i write about tech & fascinating things happening on internet so incase you don't MISS OUT, Follow me on Devto.

Also if you want to receive tech tips and how to make your life smarter using the cool stuff on the internet.
Subscribe to our weekly newsletter.

Top comments (0)