diff --git a/rsshub/blueprints/main.py b/rsshub/blueprints/main.py index 956d518..2a93ec7 100644 --- a/rsshub/blueprints/main.py +++ b/rsshub/blueprints/main.py @@ -308,16 +308,14 @@ def nhk_newseasy(category='', keywords=''): from rsshub.spiders.nhk.newseasy import ctx return render_template('main/atom.xml', **filter_content(ctx(category))) +@bp.route('/tadoku/books/') +@cache.cached(timeout=3600) +def tadoku_books(category=''): + from rsshub.spiders.tadoku.books import ctx + return render_template('main/atom.xml', **filter_content(ctx(category))) + @bp.route('/filter/') def rss_filter(): from rsshub.spiders.rssfilter.filter import ctx feed_url = request.args.get("feed") - return render_template('main/atom.xml', **filter_content(ctx(feed_url))) -''' -@bp.route('/test') -@bp.route('/test/测试') -def test(): - import sys - # return sys.getdefaultencoding() - return sys.stdout.encoding -''' \ No newline at end of file + return render_template('main/atom.xml', **filter_content(ctx(feed_url))) \ No newline at end of file diff --git a/rsshub/spiders/tadoku/books.py b/rsshub/spiders/tadoku/books.py new file mode 100644 index 0000000..bee2860 --- /dev/null +++ b/rsshub/spiders/tadoku/books.py @@ -0,0 +1,25 @@ +import re +from rsshub.utils import DEFAULT_HEADERS +from rsshub.utils import fetch + +domain = 'https://tadoku.org' + +def parse(post): + item = {} + item['title'] = post.css('.bl-title').css('a::text').extract_first() + item['description'] = post.css('.bl-thumb').extract_first() + post.css('.bl-title').extract_first() + item['link'] = post.css('.bl-title').css('a::attr(href)').extract_first() + return item + +def ctx(category=''): + url = f"{domain}/japanese/book-search?level={category}" + tree = fetch(url,headers=DEFAULT_HEADERS) + posts = tree.css('.col-6.col-sm-4.col-md-3.col-lg-2.bl-wrap-small') + return { + 'title': f'{category} Books - TADOKU.ORG', + 'link': url, + 'description': f'Book searching result - TADOKU.ORG', + 'author': 'hillerliao', + 'items': list(map(parse, posts)) + } + diff --git a/rsshub/templates/main/feeds.html b/rsshub/templates/main/feeds.html index 66d026f..6980caf 100644 --- a/rsshub/templates/main/feeds.html +++ b/rsshub/templates/main/feeds.html @@ -230,6 +230,19 @@
+ +
+
+

TADOKU.ORG

+
图书 by hillerliao
+

举例:https://pyrsshub.vercel.app/tadoku/books/l0

+

路由:/tadoku/books/:category

+

参数:category [必填,难度等级,l0、l1、l2、l3、l4、l5 ]

+
+
+
+ +