Skip to content

Instantly share code, notes, and snippets.

@nro-bot
Created June 19, 2011 03:24
Show Gist options
  • Save nro-bot/1033725 to your computer and use it in GitHub Desktop.
Save nro-bot/1033725 to your computer and use it in GitHub Desktop.
API Wrapper Jun 18 2011
class all_api(object):
def __init__(self):
self.dictionary = {"category":"by_category/%s", "state":"all_by_state/%s", "business_state":"state_only/%s/%s"}
def by_keyword(self, *keyword):
if (len(keyword) == 2):
url = self.dictionary[keyword[0]] % (keyword[1])
elif (len(keyword) == 3):
url = str(self.dictionary[keyword[0]] % (keyword[1], keyword[2]))
elif (len(keyword) == 3):
url = str(self.dictionary[keyword[0]] % (keyword[1], keyword[2], keyword[3]))
else:
#print "Not found"
print url
all_api().by_keyword('category', 'doing business as')
all_api().by_keyword('', 'child care services', 'va')
#output: by_category/doing business as
#output: state_only/child care services/va
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment