]>
Commit | Line | Data |
---|---|---|
685e346e A |
1 | from urllib import urlencode |
2 | from feed import get_json | |
3 | ||
4 | class UrbanDictionary(object): | |
5 | def __init__(self): | |
6 | self.last_def = {} | |
7 | ||
8 | def get_definitions(self, expr): | |
9 | if expr in self.last_def: | |
10 | return self.last_def[expr] | |
11 | ||
8f20a96a | 12 | url = 'https://api.urbandictionary.com/v0/define?' |
685e346e A |
13 | url += urlencode({'term': expr}) |
14 | j = get_json(url) | |
15 | self.last_def = {expr: j} | |
16 | return j |