format weiyangx.express by flake8

This commit is contained in:
hillerliao
2020-04-12 12:52:34 +08:00
parent ebbae015bc
commit 6620af70bb
4 changed files with 53 additions and 1 deletions

View File

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

View File

@@ -17,7 +17,6 @@ def ctx(category=''):
res = requests.get(url, headers=DEFAULT_HEADERS) res = requests.get(url, headers=DEFAULT_HEADERS)
res = json.loads(res.text) res = json.loads(res.text)
posts = res posts = res
print(posts)
items = list(map(parse, posts)) items = list(map(parse, posts))
return { return {
'title': f'{category} - tag - Techcrunch', 'title': f'{category} - tag - Techcrunch',

View File

@@ -0,0 +1,36 @@
import requests
import json
from rsshub.utils import DEFAULT_HEADERS
domain = 'https://www.weiyangx.com'
def parse(post):
item = {}
item['title'] = post['post_title']
item['description'] = post['post_content']
post_id = post['post_id']
item['link'] = f'{domain}/{post_id}.html'
item['pubDate'] = post['post_date'][0] + '-' + \
post['post_date'][1] + '-' + \
post['post_date'][2]
return item
def ctx():
url = f'https://www.weiyangx.com/wp-admin/admin-ajax.php'
q_data = {"action": "load_more_express",
"offset": "00",
"category": "29817",
"_ajax_nonce": "235111d38c"}
res = requests.post(url, data=q_data, headers=DEFAULT_HEADERS)
posts = json.loads(res.text)['expressList']
items = list(map(parse, posts))
return {
'title': f'快讯 - 未央网',
'description': f'快讯 - 未央网',
'link': f'{domain}/category/express',
'author': f'hillerliao',
'items': items
}

View File

@@ -203,4 +203,16 @@
<br> <br>
<!--item info end--> <!--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://rsshub-python.herokuapp.com/weiyangx/express/" target="_blank">https://rsshub-python.herokuapp.com/weiyangx/express/</a></p>
<p class="card-text">路由:<code>/weiyangx/express/</code></p>
</div>
</div>
<br>
<!--item info end-->
{% endblock content %} {% endblock content %}