Common libraries

This commit is contained in:
Sasha MOREL 2017-11-18 16:40:49 +01:00
parent 9c96d0f823
commit 265204e6b6
1 changed files with 17 additions and 0 deletions

17
libs.py Normal file
View File

@ -0,0 +1,17 @@
'''
Common libraries
'''
from json import loads as read_json
from urllib import request
from urllib.error import HTTPError
def get_data_from_json (url):
'''
gets data from json at url
'''
opener = request.build_opener ()
try:
return (read_json (opener.open (url).read ().decode ('utf8')))
except HTTPError:
return (None)