Finished Kanji search
This commit is contained in:
parent
67b50c3b8c
commit
68bf4ccba5
|
@ -38,11 +38,13 @@ class Kanji(commands.Cog):
|
||||||
)
|
)
|
||||||
|
|
||||||
if node.kun:
|
if node.kun:
|
||||||
embed.add_field(name="Kun", value=", ".join(node.kun), inline=False)
|
embed.add_field(name="Kun", value="、 ".join(node.kun), inline=False)
|
||||||
if node.on:
|
if node.on:
|
||||||
embed.add_field(name="On", value=", ".join(node.on), inline=False)
|
embed.add_field(name="On", value="、 ".join(node.on), inline=False)
|
||||||
|
|
||||||
embed.set_footer(text=f"{self.activeObject.page + 1}/{self.activeObject.total_pages}")
|
embed.add_field(name=f"Radical: {node.radical[0]}", value=node.radical[1], inline=False)
|
||||||
|
|
||||||
|
embed.set_footer(text=f"Jōyō kanji (Grade {node.grade}) | JLPT level {node.jlpt}\t\t{self.activeObject.page + 1}/{self.activeObject.total_pages}")
|
||||||
|
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import requests
|
import requests
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import json
|
import json
|
||||||
|
import re
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
TEMPLATE_URL = "https://jisho.org/api/v1/search/words?keyword={0}"
|
TEMPLATE_URL = "https://jisho.org/api/v1/search/words?keyword={0}"
|
||||||
|
@ -90,7 +91,7 @@ class JishoKanjiNode():
|
||||||
self.meaning = ""
|
self.meaning = ""
|
||||||
self.kun = []
|
self.kun = []
|
||||||
self.on = []
|
self.on = []
|
||||||
self.radical = ""
|
self.radical = []
|
||||||
self.grade = ""
|
self.grade = ""
|
||||||
self.jlpt = ""
|
self.jlpt = ""
|
||||||
|
|
||||||
|
@ -144,6 +145,14 @@ class JishoKanji():
|
||||||
self.nodes[-1].on.append(reading.string)
|
self.nodes[-1].on.append(reading.string)
|
||||||
|
|
||||||
# Radical
|
# Radical
|
||||||
radical_block = readings_block.findChild("div", {"class": "radicals"}, recursive=True)
|
radical_block = info.findChild("div", {"class": "radicals"}, recursive=True).findChild("span")
|
||||||
print(radical_block)
|
self.nodes[-1].radical.append(re.sub(r'[ \n"]', "", radical_block.contents[2].string))
|
||||||
|
self.nodes[-1].radical.append(re.sub(r'[ \n"]', "", radical_block.contents[1].string))
|
||||||
|
|
||||||
|
# JLPT/Grade info
|
||||||
|
grade_block = info.findChild("div", {"class": "grade"}, recursive=True)
|
||||||
|
if grade_block != None:
|
||||||
|
self.nodes[-1].grade = grade_block.findChild("strong").string[-1]
|
||||||
|
|
||||||
|
self.nodes[-1].jlpt = info.findChild("div", {"class": "jlpt"}, recursive=True).findChild("strong").string
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue