get world brief in economist

This commit is contained in:
hillerliao
2022-07-13 15:00:38 +08:00
parent 177a9ecbdf
commit 7cffb72621
3 changed files with 44 additions and 0 deletions

View 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))
}