diff --git a/rsshub/blueprints/main.py b/rsshub/blueprints/main.py index 5c27542..e2445c5 100644 --- a/rsshub/blueprints/main.py +++ b/rsshub/blueprints/main.py @@ -230,6 +230,11 @@ def appstore_top(cc='', genreid=''): from rsshub.spiders.appstore.top import ctx return render_template('main/atom.xml', **filter_content(ctx(cc,genreid))) +@bp.route('/aisixiang/search//') +def aisixiang_search(category='', keywords=''): + from rsshub.spiders.aisixiang.search import ctx + return render_template('main/atom.xml', **filter_content(ctx(category, keywords))) + @bp.route('/filter/') def rss_filter(): from rsshub.spiders.rssfilter.filter import ctx diff --git a/rsshub/spiders/aisixiang/search.py b/rsshub/spiders/aisixiang/search.py new file mode 100644 index 0000000..d392519 --- /dev/null +++ b/rsshub/spiders/aisixiang/search.py @@ -0,0 +1,27 @@ +import urllib.parse +from rsshub.utils import fetch, DEFAULT_HEADERS + + +domain = 'https://www.aisixiang.com' + + +def parse(post): + item = {} + item['description'] = item['title'] = post.css('a::text').getall()[-1] + item['link'] = f"{domain}{post.css('a::attr(href)').getall()[-1]}" + item['pubDate'] = post.css('span::text').extract_first() + return item + + +def ctx(category='', keywords=''): + keywords_encode = urllib.parse.quote(keywords, encoding='gbk') + url = f"{domain}/data/search.php?keyWords={keywords_encode}&searchfield={category}" + tree = fetch(url, headers=DEFAULT_HEADERS) + posts = tree.css('.search_list').css('li') + return { + 'title': f'{keywords} - {category}搜索 - 爱思想', + 'link': url, + 'description': f'{keywords} - {category}搜索 - 爱思想', + 'author': 'hillerliao', + 'items': list(map(parse, posts)) + } diff --git a/rsshub/templates/main/feeds.html b/rsshub/templates/main/feeds.html index a46962a..c4c6f86 100644 --- a/rsshub/templates/main/feeds.html +++ b/rsshub/templates/main/feeds.html @@ -11,7 +11,7 @@

参数:exclude_title 排除标题

参数:exclude_description 排除摘要

参数:limit 限制条数

- +
@@ -195,6 +195,19 @@
+ +
+
+

爱思想搜索结果

+
爱思想搜索结果 by hillerliao
+

举例:https://pyrsshub.vercel.app/aisixiang/search/author/郑永年

+

路由:/aisixiang/search/:category/:keywords

+

参数:category [必填,author|title|keywords], keywords 必填

+
+
+
+ +
@@ -428,11 +441,11 @@
-

Producthunt - 搜索结果

-
Producthunt - 搜索结果 by hillerliao
+

Producthunt - 搜索结果

+
Producthunt - 搜索结果 by hillerliao

举例:https://pyrsshub.vercel.app/producthunt/search/wechat/30

路由:/producthunt/search/:keyword/:period

-

keyword [必填, 搜索关键词],period,[必填, 时间范围]

+

keyword [必填, 搜索关键词],period,[必填, 时间范围]


@@ -445,7 +458,7 @@
蒲公英 - App 更新日志by hillerliao

举例:https://pyrsshub.vercel.app/pgyer/22bY

路由:/pgyer/:pageid

-

pageid [必填, 页面 id]

+

pageid [必填, 页面 id]