Added jisho api interface
This commit is contained in:
parent
3567edfc17
commit
7c0e643ecc
2 changed files with 23 additions and 1 deletions
14
utils/jisho.py
Normal file
14
utils/jisho.py
Normal 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)
|
Loading…
Add table
Add a link
Reference in a new issue