Files
RSSHub-python/rsshub/spiders/mp/youwuqiong.py
2021-08-25 11:50:49 +08:00

37 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from icecream import ic
from rsshub.utils import fetch
from rsshub.utils import DEFAULT_HEADERS
domain = 'https://youwuqiong.com'
def get_content(url):
tree = fetch(url=url,headers=DEFAULT_HEADERS)
content = tree.css('.single-content').get()
return content
def parse(post):
item = {}
item['description'] = post.css('p::text').get()
item['title'] = post.css('a::text')[1].get()
item['link'] = post.css('a::attr(href)')[1].get()
item['pubDate'] = post.css('time::text').extract_first()
# item['description'] = get_content(item['link'])
# ic(item['description'])
return item
def ctx(author=''):
url = f"{domain}/author/{author}"
tree = fetch(url=url,headers=DEFAULT_HEADERS)
html = tree.css('body')
mp_name = html.css('h1::text').get().split('')[-1]
mp_description = html.css('.archive-description::text').get()
posts = html.css('.entry-content-wrap')
return {
'title': f'{mp_name} - 公众号',
'link': url,
'description': mp_description,
'author': 'hillerliao',
'items': list(map(parse, posts))
}