mirror of
https://github.com/d0zingcat/RSSHub-python.git
synced 2026-06-14 07:26:47 +00:00
add jlpt n3 word
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import re
|
||||
import csv
|
||||
import random
|
||||
import requests
|
||||
@@ -18,12 +19,22 @@ def get_csv_line(url):
|
||||
random_line = random.choice(data)
|
||||
return random_line
|
||||
|
||||
def remove_html_tags(text):
|
||||
"""Remove html tags from a string"""
|
||||
clean = re.compile('<.*?>')
|
||||
return re.sub(clean, '', text)
|
||||
|
||||
def ctx(category=''):
|
||||
word = ''
|
||||
if category == 'ja':
|
||||
url = 'https://raw.githubusercontent.com/hillerliao/img/main/words.csv'
|
||||
res = get_csv_line(url)
|
||||
word = f"{res[1]} 〔{res[2]} {res[4]}〕 {res[3]} "
|
||||
elif category == 'jlpt3':
|
||||
url = 'https://raw.githubusercontent.com/hillerliao/img/main/hongbaoshu_N3.csv'
|
||||
res = get_csv_line(url)
|
||||
word = f"{res[0]}〔{res[1]} {res[2]}〕 ➡{res[3]} ➡{res[4]} ➡ {res[5]} ➡ {res[6]} "
|
||||
word = remove_html_tags(word)
|
||||
else:
|
||||
file = path.join(file_path,'toeflwords.txt')
|
||||
with open(file, encoding='utf-8') as inf:
|
||||
|
||||
Reference in New Issue
Block a user