提交 329525d2 编写于 作者: H hjdhnx

增加模板

上级 ee72f8f9
...@@ -39,6 +39,7 @@ class CMS: ...@@ -39,6 +39,7 @@ class CMS:
self.retry_count = new_conf.get('RETRY_CNT',3) self.retry_count = new_conf.get('RETRY_CNT',3)
self.lazy_mode = new_conf.get('LAZYPARSE_MODE') self.lazy_mode = new_conf.get('LAZYPARSE_MODE')
self.ocr_api = new_conf.get('OCR_API') self.ocr_api = new_conf.get('OCR_API')
self.cate_exclude = new_conf.get('CATE_EXCLUDE','')
try: try:
self.vod = redirect(url_for('vod')).headers['Location'] self.vod = redirect(url_for('vod')).headers['Location']
except: except:
...@@ -352,6 +353,7 @@ class CMS: ...@@ -352,6 +353,7 @@ class CMS:
r.encoding = self.encoding r.encoding = self.encoding
html = r.text html = r.text
# print(html) # print(html)
# print(self.headers)
if self.class_parse and not has_cache: if self.class_parse and not has_cache:
p = self.class_parse.split(';') p = self.class_parse.split(';')
# print(p) # print(p)
...@@ -364,6 +366,9 @@ class CMS: ...@@ -364,6 +366,9 @@ class CMS:
# print(items) # print(items)
for item in items: for item in items:
title = pdfh(item, p[1]) title = pdfh(item, p[1])
# 过滤排除掉标题名称
if self.cate_exclude and jsp.test(self.cate_exclude, title):
continue
url = pd(item, p[2]) url = pd(item, p[2])
# print(url) # print(url)
tag = url tag = url
......
...@@ -31,4 +31,5 @@ UNAME = 'admin' # 管理员账号 ...@@ -31,4 +31,5 @@ UNAME = 'admin' # 管理员账号
PWD = 'drpy' # 管理员密码 PWD = 'drpy' # 管理员密码
MAX_CONTENT_LENGTH = 1 * 1024 * 1024/100 # 100 kB MAX_CONTENT_LENGTH = 1 * 1024 * 1024/100 # 100 kB
LIVE_MODE = 1 # 0 本地 1外网 LIVE_MODE = 1 # 0 本地 1外网
CATE_EXCLUDE = '首页|留言' # 动态分类过滤
# {% if config.WALL_PAPER %}"wallpaper":"{{ config.WALL_PAPER }}",{% endif %} # {% if config.WALL_PAPER %}"wallpaper":"{{ config.WALL_PAPER }}",{% endif %}
\ No newline at end of file
var rule = Object.assign(muban.vfed,{
title:'VIP影院',
host:'http://360yy.cn',
url:'/index.php/vod/show/id/fyclass/page/fypage.html',
searchUrl:'/index.php/vod/search/page/fypage/wd/**.html',
});
\ No newline at end of file
...@@ -74,6 +74,27 @@ var muban = { ...@@ -74,6 +74,27 @@ var muban = {
一级:'.stui-vodlist li;a&&title;a&&data-original;.pic-text&&Text;a&&href', 一级:'.stui-vodlist li;a&&title;a&&data-original;.pic-text&&Text;a&&href',
二级:{"title":".stui-content__detail .title&&Text;.stui-content__detail p:eq(-2)&&Text","img":".stui-content__thumb .lazyload&&data-original","desc":".stui-content__detail p:eq(0)&&Text;.stui-content__detail p:eq(1)&&Text;.stui-content__detail p:eq(2)&&Text","content":".detail&&Text","tabs":".stui-vodlist__head h3","lists":".stui-content__playlist:eq(#id) li"}, 二级:{"title":".stui-content__detail .title&&Text;.stui-content__detail p:eq(-2)&&Text","img":".stui-content__thumb .lazyload&&data-original","desc":".stui-content__detail p:eq(0)&&Text;.stui-content__detail p:eq(1)&&Text;.stui-content__detail p:eq(2)&&Text","content":".detail&&Text","tabs":".stui-vodlist__head h3","lists":".stui-content__playlist:eq(#id) li"},
搜索:'#searchList li;a&&title;.lazyload&&data-original;.text-muted&&Text;a&&href;.text-muted:eq(-1)&&Text', 搜索:'#searchList li;a&&title;.lazyload&&data-original;.text-muted&&Text;a&&href;.text-muted:eq(-1)&&Text',
},
vfed:{
title:'',
host:'',
url:'/index.php/vod/show/id/fyclass/page/fypage.html',
searchUrl:'/index.php/vod/search/page/fypage/wd/**.html',
searchable:0,
quickSearch:0,
headers:{
'User-Agent':'UC_UA',
},
// class_parse:'.fed-pops-navbar&&ul.fed-part-rows&&a.fed-part-eone:gt(0):lt(5);a&&Text;a&&href;.*/(.*?).html',
class_parse:'.fed-pops-navbar&&ul.fed-part-rows&&a;a&&Text;a&&href;.*/(.*?).html',
play_parse:true,
lazy:'',
limit:6,
推荐:'ul.fed-list-info.fed-part-rows;li;a.fed-list-title&&Text;a&&data-original;.fed-list-remarks&&Text;a&&href',
double:true, // 推荐内容是否双层定位
一级:'.stui-vodlist li;a&&title;a&&data-original;.pic-text&&Text;a&&href',
二级:{"title":".stui-content__detail .title&&Text;.stui-content__detail p:eq(-2)&&Text","img":".stui-content__thumb .lazyload&&data-original","desc":".stui-content__detail p:eq(0)&&Text;.stui-content__detail p:eq(1)&&Text;.stui-content__detail p:eq(2)&&Text","content":".detail&&Text","tabs":".stui-vodlist__head h3","lists":".stui-content__playlist:eq(#id) li"},
搜索:'#searchList li;a&&title;.lazyload&&data-original;.text-muted&&Text;a&&href;.text-muted:eq(-1)&&Text',
} }
......
...@@ -8,6 +8,7 @@ var rule = { ...@@ -8,6 +8,7 @@ var rule = {
}, },
timeout:5000, timeout:5000,
class_parse:'#side-menu:lt(1) li;a&&Text;a&&href;com/(.*?)/', class_parse:'#side-menu:lt(1) li;a&&Text;a&&href;com/(.*?)/',
limit:5,
play_parse:true, play_parse:true,
lazy:'', lazy:'',
一级:'.col-sm-6;h3&&Text;img&&data-src;.date&&Text;a&&href', 一级:'.col-sm-6;h3&&Text;img&&data-src;.date&&Text;a&&href',
......
无法预览此类型文件
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
[搭建教程](./安卓本地搭建说明.md) | [install_help](./安卓本地搭建说明.md) [搭建教程](./安卓本地搭建说明.md) | [install_help](./安卓本地搭建说明.md)
[dr项目QQ官群](https://qm.qq.com/cgi-bin/qm/qr?k=H2KwcXrMdiR5M2blHR5gjZzPfN_S3N_C&jump_from=webapi) [dr项目QQ官群](https://qm.qq.com/cgi-bin/qm/qr?k=H2KwcXrMdiR5M2blHR5gjZzPfN_S3N_C&jump_from=webapi)
###### 更新日志 ###### 更新日志
###### 2022/09/01
- [X] 1.增加动态分类排除配置
- [X] 2.优化pdfh,pdfa,pd等函数,支持多个&&写法,自动取第一个
- [X] 3.增加vfed规则模板
###### 2022/08/31 ###### 2022/08/31
- [X] 1.增加管理员登录功能 - [X] 1.增加管理员登录功能
- [X] 2.增加管理员上传和删除内置规则功能 - [X] 2.增加管理员上传和删除内置规则功能
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
padding-left:10px; padding-left:10px;
/*padding-top:10px;*/ /*padding-top:10px;*/
margin-left:10px; margin-left:10px;
width: 240px; width: 360px;
height: 30px; height: 30px;
} }
.green { .green {
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
padding-left:10px; padding-left:10px;
/*padding-top:10px;*/ /*padding-top:10px;*/
margin-left:10px; margin-left:10px;
width: 240px; width: 360px;
height: 30px; height: 30px;
} }
.btn{ .btn{
...@@ -47,6 +47,19 @@ ...@@ -47,6 +47,19 @@
color:#FFFFFF; color:#FFFFFF;
background-color: #1379cb; background-color: #1379cb;
} }
.view_home{
letter-spacing:5px;
margin-left:20px;
width: 150px;
height: 30px;
text-align: center;
border-style: solid;
/*border-color: #8CD4F5;*/
border-color: #17af30;
text-decoration:none;
color:#FFFFFF;
background-color: #17af30;
}
/*li a {*/ /*li a {*/
/* display: block !important;*/ /* display: block !important;*/
/*}*/ /*}*/
...@@ -60,6 +73,12 @@ ...@@ -60,6 +73,12 @@
location.href = '/admin/view/'+rule+'.js'; location.href = '/admin/view/'+rule+'.js';
}); });
$(".view_home").click(function(){
// location.reload();
let rule = this.getAttribute('value').trim();
location.href = '/vod?rule='+rule;
});
$(".clear").click(function(){ $(".clear").click(function(){
// location.reload(); // location.reload();
// let rule = this.innerText.trim(); // let rule = this.innerText.trim();
...@@ -137,11 +156,13 @@ ...@@ -137,11 +156,13 @@
{% if rule.name|length > 2 %} {% if rule.name|length > 2 %}
<li class="red"> <li class="red">
<a class="view" href="javascript:void(0);">{{ rule.name }}</a> <a class="view" href="javascript:void(0);">{{ rule.name }}</a>
<a class="view_home" href="javascript:void(0);" value="{{ rule.name }}">主页数据预览</a>
<a class="clear" href="javascript:void(0);" value="{{ rule.name }}">删除</a> <a class="clear" href="javascript:void(0);" value="{{ rule.name }}">删除</a>
</li> </li>
{% else %} {% else %}
<li class="green"> <li class="green">
<a class="view" href="javascript:void(0);">{{ rule.name }}</a> <a class="view" href="javascript:void(0);">{{ rule.name }}</a>
<a class="view_home" href="javascript:void(0);" value="{{ rule.name }}">主页数据预览</a>
<a class="clear" href="javascript:void(0);" value="{{ rule.name }}">删除</a> <a class="clear" href="javascript:void(0);" value="{{ rule.name }}">删除</a>
</li> </li>
{% endif %} {% endif %}
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
<div class="btn" style="display: none"> <div class="btn" style="display: none">
<a href="/clear?rule=">缓存清理接口</a> <a href="/clear?rule=">缓存清理接口</a>
</div> </div>
<div class="btn"> <div class="btn" style="display: none">
<a href="/vod?rule=">猫CMS接口</a> <a href="/vod?rule=">猫CMS接口</a>
</div> </div>
<div class="btn"> <div class="btn">
......
...@@ -6,21 +6,32 @@ ...@@ -6,21 +6,32 @@
from pyquery import PyQuery as pq from pyquery import PyQuery as pq
from urllib.parse import urljoin from urllib.parse import urljoin
import re
class jsoup: class jsoup:
def __init__(self,MY_URL=''): def __init__(self,MY_URL=''):
self.MY_URL = MY_URL self.MY_URL = MY_URL
def test(self, text, string):
searchObj = re.search(rf'{text}', string, re.M | re.I)
test_ret = True if searchObj else False
return test_ret
def pdfh(self,html,parse,pd=False): def pdfh(self,html,parse,pd=False):
if not parse: if not parse:
return '' return ''
doc = pq(html) doc = pq(html)
option = None option = None
if parse.find('&&') > -1: if parse.find('&&') > -1:
option = parse.split('&&')[1] option = parse.split('&&')[-1]
parse = parse.split('&&')[0] parse = parse.split('&&')[:-1] # 如果只有一个&& 取的就直接是0
if len(parse) > 1: # 如果不大于1可能就是option操作,不需要拼eq
parse = ' '.join([i if self.test(':eq|:lt|:gt',i) else f'{i}:eq(0)' for i in parse])
else:
parse = parse[0] if self.test(':eq|:lt|:gt',parse[0]) else f'{parse[0]}:eq(0)'
if option: if option:
# print(f'parse:{parse}=>(option:{option})')
ret = doc(parse) ret = doc(parse)
# FIXME 解析出来有多个的情况应该自动取第一个 # FIXME 解析出来有多个的情况应该自动取第一个
if option == 'Text': if option == 'Text':
...@@ -44,6 +55,11 @@ class jsoup: ...@@ -44,6 +55,11 @@ class jsoup:
def pdfa(self,html,parse): def pdfa(self,html,parse):
if not parse: if not parse:
return [] return []
if parse.find('&&') > -1:
parse = parse.split('&&') # 带&&的重新拼接
# print(f"{parse[0]},{self.test(':eq|:lt|:gt', parse[0])}")
parse = ' '.join([parse[i] if self.test(':eq|:lt|:gt', parse[i]) or i>=len(parse)-1 else f'{parse[i]}:eq(0)' for i in range(len(parse))])
# print(f'pdfa:{parse}')
doc = pq(html) doc = pq(html)
# return [item.html() for item in doc(parse).items()] # return [item.html() for item in doc(parse).items()]
return [str(item) for item in doc(parse).items()] return [str(item) for item in doc(parse).items()]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册