mirror of
https://github.com/d0zingcat/RSSHub-python.git
synced 2026-05-14 15:09:23 +00:00
get world brief in economist
This commit is contained in:
@@ -200,6 +200,11 @@ def pgyer_app(category=''):
|
||||
from rsshub.spiders.pgyer.app import ctx
|
||||
return render_template('main/atom.xml', **filter_content(ctx(category)))
|
||||
|
||||
@bp.route('/economist/worldbrief')
|
||||
def economist_wordlbrief(category=''):
|
||||
from rsshub.spiders.economist.worldbrief import ctx
|
||||
return render_template('main/atom.xml', **filter_content(ctx(category)))
|
||||
|
||||
@bp.route('/mp/gh/<string:gh>')
|
||||
def mp_gh(gh=''):
|
||||
from rsshub.spiders.mp.gh import ctx
|
||||
|
||||
27
rsshub/spiders/economist/worldbrief.py
Normal file
27
rsshub/spiders/economist/worldbrief.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import re
|
||||
from rsshub.utils import DEFAULT_HEADERS
|
||||
from rsshub.utils import fetch
|
||||
|
||||
domain = 'https://www.economist.com'
|
||||
|
||||
def parse(post):
|
||||
item = {}
|
||||
item['title'] = post.css('div.e18qdnq10').get()
|
||||
item['title'] = re.sub(r'<[^>]*>', '', item['title']).strip()
|
||||
item['description'] = item['title']
|
||||
link = f"{domain}/the-world-in-brief"
|
||||
return item
|
||||
|
||||
def ctx(category=''):
|
||||
url = f"{domain}/the-world-in-brief"
|
||||
tree = fetch(url,headers=DEFAULT_HEADERS)
|
||||
posts = tree.css('._gobbet')
|
||||
|
||||
return {
|
||||
'title': f'World Brief - Economist',
|
||||
'link': url,
|
||||
'description': f'The world in brief: Catch up quickly on the global stories that matter',
|
||||
'author': 'hillerliao',
|
||||
'items': list(map(parse, posts))
|
||||
}
|
||||
|
||||
@@ -30,6 +30,18 @@
|
||||
<br>
|
||||
<!--item info end-->
|
||||
|
||||
<!--item info start-->
|
||||
<div class="card text-left">
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">The world in brief - The Economist</h4>
|
||||
<h6 class="text-muted">World Brief <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/economist/worldbrief" target="_blank">https://pyrsshub.vercel.app/economist/worldbrief</a></p>
|
||||
<p class="card-text">路由:<code>/economist/worldbrief</code></p>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<!--item info end-->
|
||||
|
||||
<div class="card text-left">
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">传送门-失效</h4>
|
||||
|
||||
Reference in New Issue
Block a user