add weiyangx article in tag

This commit is contained in:
hillerliao
2020-04-12 14:50:43 +08:00
parent 6620af70bb
commit a0bfac9f3e
3 changed files with 51 additions and 0 deletions

View File

@@ -125,3 +125,8 @@ def techcrunch_tag(category=''):
def weiyangx_express():
from rsshub.spiders.weiyangx.express import ctx
return render_template('main/atom.xml', **filter_content(ctx()))
@bp.route('/weiyangx/tag/<string:category>')
def weiyangx_tag(category=''):
from rsshub.spiders.weiyangx.tag import ctx
return render_template('main/atom.xml', **filter_content(ctx(category)))

View File

@@ -0,0 +1,33 @@
import requests
import json
from rsshub.utils import DEFAULT_HEADERS
domain = 'https://www.weiyangx.com'
def parse(post):
item = {}
item['title'] = post['title']
item['description'] = post['content']
item['link'] = post['url']
item['author'] = post['authorMeta']
return item
def ctx(category=''):
url = f'https://www.weiyangx.com/wp-admin/admin-ajax.php'
q_data = {"action": "home_load_more_news",
"postOffset": "00",
"tagId": category,
"_ajax_nonce": "1846edad4e"}
res = requests.post(url, data=q_data, headers=DEFAULT_HEADERS)
posts = json.loads(res.text)['data']
items = list(map(parse, posts))
return {
'title': f'快讯 - 未央网',
'description': f'快讯 - 未央网',
'link': f'{domain}/category/express',
'author': f'hillerliao',
'items': items
}

View File

@@ -215,4 +215,17 @@
<br>
<!--item info end-->
<!--item info start-->
<div class="card text-left">
<div class="card-body">
<h4 class="card-title">未央网 tag文章列表</h4>
<h6 class="text-muted">未央网 tag文章列表 <a href="https://github.com/hillerliao" target="_blank" class="badge badge-secondary">by hillerliao</a></h6>
<p class="card-text">举例:<a href="https://rsshub-python.herokuapp.com/weiyangx/tag/270" target="_blank">https://rsshub-python.herokuapp.com/weiyangx/tag/270</a></p>
<p class="card-text">路由:<code>/weiyangx/tag/:category</code></p>
<p class="card-text">参数category [必填,见 weiyangx 官网]</p>
</div>
</div>
<br>
<!--item info end-->
{% endblock content %}