mirror of
https://github.com/d0zingcat/RSSHub-python.git
synced 2026-05-18 07:26:48 +00:00
lightly init
This commit is contained in:
6
.lightly/settings.toml
Normal file
6
.lightly/settings.toml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
title = "lightly settings"
|
||||||
|
|
||||||
|
ports = []
|
||||||
|
|
||||||
|
[languages]
|
||||||
20
main.py
20
main.py
@@ -1,10 +1,10 @@
|
|||||||
import os
|
import os
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
dotenv_path = os.path.join(os.path.dirname(__file__), '.env')
|
dotenv_path = os.path.join(os.path.dirname(__file__), '.env')
|
||||||
if os.path.exists(dotenv_path):
|
if os.path.exists(dotenv_path):
|
||||||
load_dotenv(dotenv_path)
|
load_dotenv(dotenv_path)
|
||||||
|
|
||||||
from rsshub import create_app
|
from rsshub import create_app
|
||||||
|
|
||||||
app = create_app('production')
|
app = create_app('production')
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
from rsshub.utils import fetch
|
from rsshub.utils import fetch
|
||||||
|
|
||||||
domain = 'http://www.bjnews.com.cn'
|
domain = 'http://www.bjnews.com.cn'
|
||||||
|
|
||||||
|
|
||||||
def parse(post):
|
def parse(post):
|
||||||
item = {}
|
item = {}
|
||||||
item['description'] = item['title'] = post.css('a::text').extract_first()
|
item['description'] = item['title'] = post.css('a::text').extract_first()
|
||||||
item['link'] = post.css('a::attr(href)').extract_first()
|
item['link'] = post.css('a::attr(href)').extract_first()
|
||||||
return item
|
return item
|
||||||
|
|
||||||
|
|
||||||
def ctx(category=''):
|
def ctx(category=''):
|
||||||
r_url = f"{domain}/{category}"
|
r_url = f"{domain}/{category}"
|
||||||
tree = fetch(r_url)
|
tree = fetch(r_url)
|
||||||
html = tree.css('body')
|
html = tree.css('body')
|
||||||
posts = tree.css('.list-a').css('li')
|
posts = tree.css('.list-a').css('li')
|
||||||
channel_title = html.css('a.cur::text').extract_first().strip()
|
channel_title = html.css('a.cur::text').extract_first().strip()
|
||||||
return {
|
return {
|
||||||
'title': f'{channel_title} - 新京报',
|
'title': f'{channel_title} - 新京报',
|
||||||
'link': r_url,
|
'link': r_url,
|
||||||
'description': f'新京报「{channel_title}」频道新闻',
|
'description': f'新京报「{channel_title}」频道新闻',
|
||||||
'author': 'hillerliao',
|
'author': 'hillerliao',
|
||||||
'items': list(map(parse, posts))
|
'items': list(map(parse, posts))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user