mirror of
https://github.com/d0zingcat/RSSHub-python.git
synced 2026-06-11 23:16:54 +00:00
参数过滤支持多关键词
This commit is contained in:
@@ -27,17 +27,33 @@ def filter_content(ctx):
|
||||
exclude_description = request.args.get('exclude_description')
|
||||
limit = request.args.get('limit', type=int)
|
||||
items = ctx['items'].copy()
|
||||
items = [item for item in items if include_title in item['title']] if include_title else items
|
||||
items = [item for item in items if include_description in item['description']] if include_description else items
|
||||
items = [item for item in items if exclude_title not in item['title']] if exclude_title else items
|
||||
items = [item for item in items if exclude_description not in item['description']] if exclude_description else items
|
||||
items = items[:limit] if limit else items
|
||||
|
||||
if include_title:
|
||||
include_keywords = include_title.split('|') if '|' in include_title else [include_title]
|
||||
items = [item for item in items if any(keyword in item['title'] for keyword in include_keywords)]
|
||||
|
||||
if include_description:
|
||||
include_keywords = include_description.split('|') if '|' in include_description else [include_description]
|
||||
items = [item for item in items if any(keyword in item['description'] for keyword in include_keywords)]
|
||||
|
||||
if exclude_title:
|
||||
exclude_keywords = exclude_title.split('|') if '|' in exclude_title else [exclude_title]
|
||||
items = [item for item in items if all(keyword not in item['title'] for keyword in exclude_keywords)]
|
||||
|
||||
if exclude_description:
|
||||
exclude_keywords = exclude_description.split('|') if '|' in exclude_description else [exclude_description]
|
||||
items = [item for item in items if all(keyword not in item['description'] for keyword in exclude_keywords)]
|
||||
|
||||
if limit:
|
||||
items = items[:limit]
|
||||
|
||||
ctx = ctx.copy()
|
||||
ctx['items'] = items
|
||||
return ctx
|
||||
|
||||
|
||||
|
||||
|
||||
#---------- feed路由从这里开始 -----------#
|
||||
@bp.route('/cninfo/announcement/<string:stock_id>/<string:category>')
|
||||
@bp.route('/cninfo/announcement')
|
||||
|
||||
@@ -27,11 +27,11 @@ def remove_html_tags(text):
|
||||
def ctx(category=''):
|
||||
word = ''
|
||||
if category == 'ja':
|
||||
url = 'https://raw.githubusercontent.com/hillerliao/img/main/words.csv'
|
||||
url = 'https://raw.githubusercontent.com/henrylovemiller/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'
|
||||
url = 'https://raw.githubusercontent.com/henrylovemiller/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)
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">RSS Filter参数</h4>
|
||||
<h6 class="text-muted">RSS 过滤参数<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/filter?feed=https://sspai.com/feed&include_title=派早报" target="_blank">https://pyrsshub.vercel.app/filter?feed=https://sspai.com/feed&include_title=派早报</a></p>
|
||||
<p class="card-text">参数:<code>include_title</code> 匹配标题</p>
|
||||
<p class="card-text">举例:<a href="https://pyrsshub.vercel.app/filter?feed=https://sspai.com/feed&include_title=派早报" target="_blank">https://pyrsshub.vercel.app/filter?feed=https://sspai.com/feed&include_title=征文|派早报</a></p>
|
||||
<p class="card-text">参数:<code>include_title</code> 匹配标题,支持多关键词,用 | 分隔。</p>
|
||||
<p class="card-text">参数:<code>include_description</code> 匹配摘要</p>
|
||||
<p class="card-text">参数:<code>exclude_title</code> 排除标题</p>
|
||||
<p class="card-text">参数:<code>exclude_description</code> 排除摘要</p>
|
||||
|
||||
Reference in New Issue
Block a user