Reddit Upvote/Downvote Bot

The Python script is pretty straight forward; it upvotes (or downvotes if you modify line #21) all the submissions and comments of a target user then gives you the total number of upvoted/downvoted posts when it’s done. You need a reddit account to use the bot, and make sure you go through the script and modify the lines with comments.

Usage:
  1. Copy the code below and save it on your computer.
  2. Simply input the following into your command shell: $ python [file name].py [target’s username] without the brackets.
LICENSE:

This script is under the GNU General Public License.

Disclaimer:

This script is something I put together for fun while I was playing around with Python and the Reddit API. It is far from perfect, and although it worked when I tested it in April 2012, I do not guarantee that it will continue to work forever. I will not be updating or maintaining the script. If you are against the idea of an upvote/downvote bot, do not use it. If you are a victim of someone using this script, please remember that internet points have no real value.

If you choose to use this script, do so at your own risk. Although the script follows the basic Reddit rules for bots (eg. Only one request every 2 seconds, correct user-agent name, etc.), I’m not entirely sure how happy Reddit would be if you use the script excessively. I will not be responsible for any ban or legal actions resulting from abusing this script.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import os
import sys
import time
import reddit
from reddit.objects import Redditor, Submission

__author__ = 'Sadiq Al-Khalili'
__version__ = '1.1.0'

class RedditBot(object):

    def __init__(self, uname, passwd, target):
        self.api = reddit.Reddit(user_agent='SadiqBot')     # Change 'SadiqBot' to your bot's name
        self.api.login(uname, passwd)
        self.count = 0
        self.redditor = self.api.get_redditor(target, fetch=False)

    def run(self):
        for post in self.redditor.get_overview():
            try:
                post.upvote()      # Change this to post.downvote() if you want to downvote instead
                print "Upvoted: %s" %post.__unicode__()
                self.count += 1
            except:
                exception('Cannot upvote!')
            time.sleep(2)   # Following reddit's rules

def main(target):
    bot = RedditBot('user', 'pass', target) # Change 'user' and 'pass' to your login info
    try:
        bot.run()
    except:
        raise
    finally:
        print('All done! Upvoted %d submissions/comments!' %bot.count)

    return 0

if __name__ == '__main__':
    target = sys.argv[-1]
    sys.exit(main(target))
Go to Top