mp articles from youwuqiong

This commit is contained in:
hillerliao
2021-08-25 11:50:49 +08:00
parent bd2a8dd566
commit bf1754318a
5 changed files with 433 additions and 266 deletions

View File

@@ -183,4 +183,9 @@ def mp_tag(mp='', tag=''):
@bp.route('/mp/gh/<string:gh>')
def mp_gh(gh=''):
from rsshub.spiders.mp.gh import ctx
return render_template('main/atom.xml', **filter_content(ctx(gh)))
return render_template('main/atom.xml', **filter_content(ctx(gh)))
@bp.route('/mp/youwuqiong/<string:author>')
def mp_youwuqiong(author=''):
from rsshub.spiders.mp.youwuqiong import ctx
return render_template('main/atom.xml', **filter_content(ctx(author)))

View File

@@ -0,0 +1,37 @@
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))
}

View File

@@ -337,7 +337,7 @@
<!--item info start-->
<div class="card text-left">
<div class="card-body">
<h4 class="card-title">微信公众号 - 最新文章</h4>
<h4 class="card-title">微信公众号 - 最新文章 - 搜狗方案</h4>
<h6 class="text-muted">微信公众号 - 最新文章 <a href="https://github.com/hillerliao" target="_blank" class="badge badge-secondary">by hillerliao</a></h6>
<p class="card-text">举例:<a href="https://pyrsshub.herokuapp.com/mp/gh/mao-talk" target="_blank">https://pyrsshub.herokuapp.com/mp/gh/mao-talk</a></p>
<p class="card-text">路由:<code>/mp/tag/:biz/:tag</code></p>
@@ -347,4 +347,17 @@
<br>
<!--item info end-->
<!--item info start-->
<div class="card text-left">
<div class="card-body">
<h4 class="card-title">微信公众号 - 最新文章 - 游无穷</h4>
<h6 class="text-muted">微信公众号 - 最新文章 <a href="https://github.com/hillerliao" target="_blank" class="badge badge-secondary">by hillerliao</a></h6>
<p class="card-text">举例:<a href="https://pyrsshub.herokuapp.com/mp/youwuqiong/maoyouhuashuo" target="_blank">https://pyrsshub.herokuapp.com/mp/youwuqiong/maoyouhuashuo</a></p>
<p class="card-text">路由:<code>/mp/youwuqiong/:author</code></p>
<p class="card-text">author [必填, 作者id在 youwuqiong.com 文章列表页上找] </p>
</div>
</div>
<br>
<!--item info end-->
{% endblock content %}