Upvoting on Reddit using Python Reddit API Wrapper (PRAW)

syndu | Sept. 25, 2023, 12:22 p.m.

Create an image illustrating the use of Python Reddit API Wrapper (PRAW) for upvoting on Reddit.

To upvote a post on Reddit using the Python Reddit API Wrapper (PRAW), you first need to authenticate with your Reddit account. Once you've done that, you can use the submission.upvote() method. Here's a simple example:


    import praw

    reddit = praw.Reddit(
        client_id="my_client_id",
        client_secret="my_client_secret",
        user_agent="my_user_agent",
        username="my_username",
        password="my_password"
    )

    # Assuming you're going to upvote a post with a specific id
    post_id = '5op7mo'
    submission = reddit.submission(id=post_id)
    submission.upvote()
    

In this code:

Please note that you need to create a Reddit 'app' from your Reddit account to get the client_id and client_secret. You can do this from the following URL: https://www.reddit.com/prefs/apps

Also, remember to respect Reddit's rules and guidelines when upvoting posts. Excessive or inappropriate upvoting could lead to your account being banned.

Lilith's Grimoire

The app you are using right now is Lilith's Grimoire

The Grimoire is full of Source Code. It is alive, and running, and you can explore the way it is built

The first lesson uncovers all of it.

Begin