change pgyer rss description

This commit is contained in:
hillerliao
2022-05-18 21:41:21 +08:00
parent 27b3806894
commit 82e7563700

View File

@@ -4,6 +4,16 @@ from rsshub.utils import fetch
domain = 'https://www.pgyer.com'
def parse(post):
item = {}
item['title'] = post.xpath('//meta[@property="og:description"]').attrib['content']
item['description'] = post.css('div.update-description').extract_first()
item['description'] = re.sub(r'<[^>]*>', '', item['description'] )\
.split('备注信息:')[1].split('执行人')[0].strip()
link = post.css('img.qrcode').attrib['src'].split('app/qrcode/')
item['link'] = link[0] + link[1]
return item
def ctx(category=''):
url = f"{domain}/{category}"
tree = fetch(url,headers=DEFAULT_HEADERS)
@@ -19,13 +29,3 @@ def ctx(category=''):
'items': list(map(parse, posts))
}
def parse(post):
item = {}
item['title'] = post.xpath('//meta[@property="og:description"]').attrib['content']
item['description'] = item['title'] + '' \
+ post.css('ul.breadcrumb > li::text').getall()[1] + '' \
+ post.css('ul.breadcrumb > li::text').getall()[2]
item['description'] = re.sub(r'\s|\n', '', item['description'])
link = post.css('img.qrcode').attrib['src'].split('app/qrcode/')
item['link'] = link[0] + link[1]
return item