techcrunch

This commit is contained in:
hillerliao
2020-04-04 19:58:56 +08:00
parent d631712bbe
commit 0e194cb9ed
3 changed files with 35 additions and 2 deletions

View File

@@ -49,6 +49,6 @@ flask run
### 部署到Heroku
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/alphardex/RSSHub-python)
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/hillerliao/RSSHub-python)
记得在环境变量中把FLASK_CONFIG设为production

View File

@@ -114,4 +114,9 @@ def cls_subject(category=''):
@bp.route('/chaindd/column/<string:category>')
def chaindd_column(category=''):
from rsshub.spiders.chaindd.column import ctx
return render_template('main/atom.xml', **filter_content(ctx(category)))
return render_template('main/atom.xml', **filter_content(ctx(category)))
@bp.route('/techcrunch/tag/<string:category>')
def techcrunch_tag(category=''):
from rsshub.spiders.techcrunch.tag import ctx
return render_template('main/atom.xml', **filter_content(ctx(category)))

View File

@@ -0,0 +1,28 @@
import requests
import json
from rsshub.utils import DEFAULT_HEADERS
domain = 'https://techcrunch.com'
def parse(post):
item = {}
item['title'] = post['title']['rendered']
item['description'] = post['content']['rendered']
item['link'] = post['link']
item['pubDate'] = post['date_gmt']
return item
def ctx(category=''):
url = f'{domain}/wp-json/tc/v1/magazine?tags={category}'
res = requests.get(url, headers=DEFAULT_HEADERS)
res = json.loads(res.text)
posts = res
print(posts)
items = list(map(parse, posts))
return {
'title': f'{category} - tag - Techcrunch',
'description': f'{category} - tag - Techcrunch',
'link': f'f{domain}/tag/fintech/',
'author': f'hillerliao',
'items': items
}