A1: Make 7 Reddit Posts#

Choose Social Media Platform: Reddit | Discord | Bluesky | No Coding

In this assignment, you will modify this program to post at least 7 reddit posts (no more than 15). Then you will answer some reflection questions on your bot.

We suggest that while you are working on it and testing it out, you use fake_praw so it doesn’t post on actual reddit. When you are done, you can try running it on your real reddit account, but you might just get rate limit errors. You can just run in with fake_praw and we’ll be able to see what your bot would have posted to reddit if reddit didn’t block you.

When you are done, you will need to download this file or a pdf version (file menu -> download) and turn it in on Canvas.

Code to make your posts#

step 1: load praw code#

# Load some code called "praw" that will help us work with reddit
import praw

(optional) step 1b: make a fake praw connection with the fake_praw library#

For testing purposes, we’ve added this line of code, which loads a fake version of praw, so it wont actually connect to reddit. If you want to try to actually connect to reddit, don’t run this line of code.

%run ../../../../fake_apis/fake_praw.ipynb
Fake praw is replacing the praw library. Fake praw doesn't need real passwords, and prevents you from accessing real reddit

step 2: load your developer access passwords#

To use this on your real Reddit account, copy your developer access passwords into the reddit_keys.py file.

%run reddit_keys.py

step 4: give praw (or fake_praw) your developer access passwords#

# Give the praw code your reddit account info so
# it can perform reddit actions
reddit = praw.Reddit(
    username=username, password=password,
    client_id=client_id, client_secret=client_secret,
    user_agent="a custom python script for user /" + str(username)
)
Fake praw is pretending to collect account info to use on reddit

step 4: submit 7 reddit posts#

This is where you will have to modify the code to:

Post 7 times to reddit

  • Using the sleep() function at least two times

  • Save at least one piece of text in a variable and use it for making a post

You bot must NOT:

  • Interact with other users or normal subreddits (e.g., post in /r/science, tag other users, etc.)

  • Post more than 15 times

# Post a reddit post

reddit.subreddit(
   "info_103_sp23"
).submit(
   "Example post", 
   selftext = "Example Text"
)

# TODO: modify this code to post 7 times, using the sleep() function 
# at least two times and using a variable at least once
Fake praw is pretending to select the subreddit: info_103_sp23
Fake praw is pretending to submit a post with the title: "Example post" and the content: Example Text

Reflection Questions#

You must also write answers to the following questions Note: You can double click on these blocks of text to edit them

What is the name of your reddit account so we can see the posts? Or what error message did you get when trying to make the posts? (you still get full credit even if you couldn’t get it to post for real)

TODO: Put reddit account name (or error message) here

If your reddit account wasn’t labeled as a bot, how do you think people would perceive those posts? (write at least 3 sentences)

TODO: Write at least 3 sentences here

If people saw those posts and then later discovered that they were posted by a computer program, how do you think their view of the posts would change? (write at least 3 sentences)

TODO: Write at least 3 sentences here

Pick two ethics frameworks and compare how they might evaluate your bot (or a similar one with more benevolent or malevalent purposes)? (write at least 6 sentences)

TODO: Write at least 6 sentences here