Modules: global dusting: call getJSON instead of making raw calls to urllib
This commit is contained in:
parent
66ec7cb7ca
commit
d14fec4cec
14 changed files with 118 additions and 116 deletions
|
|
@ -1,15 +1,18 @@
|
|||
# coding=utf-8
|
||||
|
||||
import json
|
||||
from urllib.parse import quote
|
||||
from urllib.request import urlopen
|
||||
|
||||
from tools import web
|
||||
|
||||
|
||||
class UrbanDictionnary:
|
||||
|
||||
def __init__(self, terms):
|
||||
self.terms = terms
|
||||
|
||||
raw = urlopen("http://api.urbandictionary.com/v0/define?term=%s" % quote(terms), timeout=10)
|
||||
self.udres = json.loads(raw.read().decode())
|
||||
self.udres = web.getJSON(
|
||||
"http://api.urbandictionary.com/v0/define?term=%s" % quote(terms),
|
||||
timeout=10)
|
||||
|
||||
@property
|
||||
def result_type(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue