old_contents: # Send_to_twitter_status
  # Had to be modified - can't follow instructions in book for Twitter
  
  import urllib.request
  import time
  import twython
  
  def send_to_twitter(msg):
      
      CONSUMER_KEY = ''
      CONSUMER_SECRET = ''
      ACCESS_KEY = ''
      ACCESS_SECRET = ''
      
      twitter = twython.Twython(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_KEY, ACCESS_SECRET)
      twitter.update_status(status=msg)    
  
  def get_price():
  
      page = urllib.request.urlopen("http://beans-r-us.appspot.com/prices-loyalty.html")
      text = page.read().decode ("utf8")
      where = text.find('>$')
      start_of_price = where + 2
      end_of_price = start_of_price + 4
      return float(text[start_of_price:end_of_price])
  
  price_now = input("Do you want to see the price now (Y/N)? ")
  
  if price_now == "Y":
      send_to_twitter(get_price())
  
  else:
      price = 99.99
      while price > 4.74:
          time.sleep(10)
          price = get_price()
      send_to_twitter("Buy!")
  
new_contents: # Send_to_twitter_status
  # Had to be modified - can't follow instructions in book for Twitter
  
  import urllib.request
  import time
  import twython
  
  def send_to_twitter(msg):
      CONSUMER_KEY = ''
      CONSUMER_SECRET = ''
      ACCESS_KEY = ''
      ACCESS_SECRET = ''
      twitter = twython.Twython(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_KEY, ACCESS_SECRET)
      twitter.update_status(status=msg)    
  
  def get_price():
      page = urllib.request.urlopen("http://beans-r-us.appspot.com/prices-loyalty.html")
      text = page.read().decode("utf-8")
      where = text.find('>$')
      start_of_price = where + 2
      end_of_price = start_of_price + 4
      return float(text[start_of_price:end_of_price])
  
  price_now = input("Do you want to see the price now (Y/N)? ")
  if price_now == "Y":
      send_to_twitter(get_price())
  else:
      price = 99.99
      while price > 4.74:
          time.sleep(10)
          price = get_price()
      send_to_twitter("Buy!")
  
subject: change decode from 'utf8' to 'utf-8'