For my twitter bot I decided to both poke fun at consumerism and create an ode to the absurdity of the breadth of the amazon product inventory. My bot tweets two random top amazon products in juxtaposition to each other, urging the viewer to buy one or the other. To do this, I scraped the names of the top 500 selling amazon products and created a python script to select 2 products at random and post them to twitter. @this_or_a_that
I wish there was a way to embed url links into the product name for easy purchasing. I also wish I could have figured out how to run this script automatically every hour using cron.
Both images are google image results for amazon ad.
Here’s some funny letters and numbers:
#Rachel Ciavarella IACD spring 2015 CMU #twitter bot assignment from twython import Twython import csv import random from random import randrange twitter = Twython("secret stuff", "secret stuff") #populate verb list from file (fill your cart like it's the void in your soul) f = open('amazon_data.csv','rU') u = open('amazon_data.csv','rU') csv_f = csv.reader(f) csv_u = csv.reader(u) product_list =  url_list =  for row in csv_f: product_list.append(row) for row in csv_u: url_list.append(row) #random product from list (pull some products at random off the shelf, you consumerist) random_product_1 = randrange(0,len(product_list)) random_product_2 = randrange(0,len(product_list)) #print random product (what's that you got in your cart??) print product_list[random_product_1] print url_list[random_product_1] print product_list[random_product_2] print url_list[random_product_2] #post two products to twitter(tell the people what they want to buy) twitter.update_status(status=product_list[random_product_1]+ ' or ' +product_list[random_product_2])