mirror of
https://github.com/d0zingcat/RSSHub-python.git
synced 2026-05-14 15:09:23 +00:00
add aisixiang search
This commit is contained in:
@@ -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/<string:category>/<string:keywords>')
|
||||
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
|
||||
|
||||
27
rsshub/spiders/aisixiang/search.py
Normal file
27
rsshub/spiders/aisixiang/search.py
Normal file
@@ -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))
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
<p class="card-text">参数:<code>exclude_title</code> 排除标题</p>
|
||||
<p class="card-text">参数:<code>exclude_description</code> 排除摘要</p>
|
||||
<p class="card-text">参数:<code>limit</code> 限制条数</p>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
@@ -195,6 +195,19 @@
|
||||
<br>
|
||||
<!--item info end-->
|
||||
|
||||
<!--item info start-->
|
||||
<div class="card text-left">
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">爱思想搜索结果</h4>
|
||||
<h6 class="text-muted">爱思想搜索结果 <a href="https://github.com/hillerliao" target="_blank" class="badge badge-secondary">by hillerliao</a></h6>
|
||||
<p class="card-text">举例:<a href="https://pyrsshub.vercel.app/aisixiang/search/author/郑永年" target="_blank">https://pyrsshub.vercel.app/aisixiang/search/author/郑永年</a></p>
|
||||
<p class="card-text">路由:<code>/aisixiang/search/:category/:keywords</code></p>
|
||||
<p class="card-text">参数:category [必填,author|title|keywords], keywords 必填</p>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<!--item info end-->
|
||||
|
||||
<!--item info start-->
|
||||
<div class="card text-left">
|
||||
<div class="card-body">
|
||||
@@ -428,11 +441,11 @@
|
||||
<!--item info start-->
|
||||
<div class="card text-left">
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">Producthunt - 搜索结果</h4>
|
||||
<h6 class="text-muted">Producthunt - 搜索结果 <a href="https://github.com/hillerliao" target="_blank" class="badge badge-secondary">by hillerliao</a></h6>
|
||||
<h4 class="card-title">Producthunt - 搜索结果</h4>
|
||||
<h6 class="text-muted">Producthunt - 搜索结果 <a href="https://github.com/hillerliao" target="_blank" class="badge badge-secondary">by hillerliao</a></h6>
|
||||
<p class="card-text">举例:<a href="https://pyrsshub.vercel.app/producthunt/search/wechat/30" target="_blank">https://pyrsshub.vercel.app/producthunt/search/wechat/30</a></p>
|
||||
<p class="card-text">路由:<code>/producthunt/search/:keyword/:period</code></p>
|
||||
<p class="card-text">keyword [必填, 搜索关键词],period,[必填, 时间范围] </p>
|
||||
<p class="card-text">keyword [必填, 搜索关键词],period,[必填, 时间范围] </p>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
@@ -445,7 +458,7 @@
|
||||
<h6 class="text-muted">蒲公英 - App 更新日志<a href="https://github.com/hillerliao" target="_blank" class="badge badge-secondary">by hillerliao</a></h6>
|
||||
<p class="card-text">举例:<a href="https://pyrsshub.vercel.app/pgyer/22bY" target="_blank">https://pyrsshub.vercel.app/pgyer/22bY</a></p>
|
||||
<p class="card-text">路由:<code>/pgyer/:pageid</code></p>
|
||||
<p class="card-text">pageid [必填, 页面 id]</p>
|
||||
<p class="card-text">pageid [必填, 页面 id]</p>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
Reference in New Issue
Block a user