add home list

This commit is contained in:
hillerliao
2020-04-13 15:30:17 +08:00
parent ea01b359c1
commit 2027fd8c5a
4 changed files with 49 additions and 22 deletions

View File

@@ -121,6 +121,11 @@ def techcrunch_tag(category=''):
from rsshub.spiders.techcrunch.tag import ctx
return render_template('main/atom.xml', **filter_content(ctx(category)))
@bp.route('/weiyangx/home')
def weiyangx_home():
from rsshub.spiders.weiyangx.home import ctx
return render_template('main/atom.xml', **filter_content(ctx()))
@bp.route('/weiyangx/express/')
def weiyangx_express():
from rsshub.spiders.weiyangx.express import ctx

View File

@@ -1,5 +1,6 @@
import requests
import json
from parsel import Selector
from rsshub.utils import DEFAULT_HEADERS
domain = 'https://www.weiyangx.com'
@@ -18,14 +19,11 @@ def parse(post):
def ctx():
url = f'https://www.weiyangx.com/wp-admin/admin-ajax.php'
q_data = {"action": "load_more_express",
"offset": "00",
"category": "29817",
"_ajax_nonce": "235111d38c"}
res = requests.post(url, data=q_data, headers=DEFAULT_HEADERS)
posts = json.loads(res.text)['expressList']
url = f'https://www.weiyangx.com/category/express'
res = requests.get(url, headers=DEFAULT_HEADERS)
res = Selector(res.text)
posts = res.css('script::text')[-4].extract().split('=')[-1]
posts = json.loads(posts)
items = list(map(parse, posts))
return {
'title': f'快讯 - 未央网',

View File

@@ -0,0 +1,31 @@
import requests
import json
from parsel import Selector
from rsshub.utils import DEFAULT_HEADERS
domain = 'https://www.weiyangx.com'
def parse(post):
item = {}
item['title'] = post['title']
item['description'] = post['content']
post_id = post['id']
item['link'] = f'{domain}/{post_id}.html'
return item
def ctx():
url = f'https://www.weiyangx.com/'
res = requests.get(url, headers=DEFAULT_HEADERS)
res = Selector(res.text)
posts = res.css('script::text')[-5].extract().split('=')[-1]
posts = json.loads(posts)
items = list(map(parse, posts))
return {
'title': f'快讯 - 未央网',
'description': f'快讯 - 未央网',
'link': f'{domain}/category/express',
'author': f'hillerliao',
'items': items
}

View File

@@ -1,28 +1,21 @@
import requests
import json
from rsshub.utils import DEFAULT_HEADERS
from rsshub.utils import fetch
domain = 'https://www.weiyangx.com'
def parse(post):
item = {}
item['title'] = post['title']
item['description'] = post['content']
item['link'] = post['url']
item['author'] = post['authorMeta']
item['title'] = post.css('h2::text').extract_first()
item['description'] = post.css('p::text').extract_first()
item['link'] = post.css('a::attr(href)').extract_first()
return item
def ctx(category=''):
url = f'https://www.weiyangx.com/wp-admin/admin-ajax.php'
q_data = {"action": "home_load_more_news",
"postOffset": "00",
"tagId": category,
"_ajax_nonce": "1846edad4e"}
res = requests.post(url, data=q_data, headers=DEFAULT_HEADERS)
posts = json.loads(res.text)['data']
url = f'https://www.weiyangx.com/tag/{category}'
tree = fetch(url, headers=DEFAULT_HEADERS)
posts = tree.css('.category-post-node')
items = list(map(parse, posts))
return {
'title': f'{category} - 文章 - 未央网',