Added jisho api interface

This commit is contained in:
Robert 2020-08-11 11:21:09 +02:00
parent 3567edfc17
commit 7c0e643ecc
2 changed files with 23 additions and 1 deletions

14
utils/jisho.py Normal file
View file

@ -0,0 +1,14 @@
import requests
import urllib.parse
import json
TEMPLATE_URL = "https://jisho.org/api/v1/search/words?keyword={0}"
def query(query: str):
url = TEMPLATE_URL.format(urllib.parse.quote_plus(query))
r = requests.get(url)
if r.status_code != 200:
print(f"ERROR: Failed to access Jisho API... {r.status_code}")
return json.loads(r.text)