#!/bin/env python # # http://www.urbandictionary.com/define.php?term=cowpatty # # INFO: This softwre works well with using one word search term from # urbandictionary.com # need to find a more efficient way to take in words with hyphen and seperated # by spaces. If it doesn't find a word you are looking for then it will prompt # an user # to continue or end this program. Need to find a way to remove the html tags. # ################################################################################### author = "YXNjaGVuYmFjaEBnbWFpbC5jb20=" import base64 import sys def askForInputs(): print "" k1 = raw_input("Please enter a word ? ") k1 = k1.lower() # the second part has some weird effect when used if k1 != "": # is not None: setWebValues(k1) else: again = raw_input("Inputs are not Strings, try again [Y/y or N/n] ? ") again = again.lower() if again == 'y': askForInputs() else: print "" print "Thanks for using this simple text software. " def setWebValues(key1): import requests import sys try: from BeautifulSoup import BeautifulSoup except ImportError: from bs4 import BeautifulSoup s = requests.Session() payload = {"term":key1} r = s.get("http://www.urbandictionary.com/define.php", params=payload) page = BeautifulSoup(r.content) # i think i have fixed this neworking closing issue on linux. if sys.platform == "win32": r.connection.close() locateDef(page) def locateDef(wp): z = wp.findAll("div", {"class": "definition"}) a = 0 while a < len(z): print z[a] a = a + 1 print "" again = raw_input("Would you like to enter another word [Y/y or N/n] ? ") again.strip() again = again.lower() if again == 'y': askForInputs() else: print "" print "Thanks for using this simple text software." def main(): askForInputs() sys.exit() main()