Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
mine929
dr_py
提交
33224bc7
dr_py
项目概览
mine929
/
dr_py
与 Fork 源项目一致
Fork自
晚风拂柳颜 / dr_py
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
dr_py
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
33224bc7
编写于
8月 26, 2022
作者:
H
hjdhnx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加了清缓存的操作
上级
053577e4
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
100 addition
and
4 deletion
+100
-4
app.py
app.py
+16
-1
readme.md
readme.md
+1
-1
static/js/jquery.min.js
static/js/jquery.min.js
+5
-0
templates/index.html
templates/index.html
+11
-2
templates/rules.html
templates/rules.html
+67
-0
未找到文件。
app.py
浏览文件 @
33224bc7
...
...
@@ -13,7 +13,7 @@ import codecs
from
models.cms
import
CMS
sys
.
stdout
=
codecs
.
getwriter
(
"utf-8"
)(
sys
.
stdout
.
detach
())
app
=
Flask
(
__name__
)
app
=
Flask
(
__name__
,
static_folder
=
'static'
,
static_url_path
=
'/static'
)
app
.
config
[
"JSON_AS_ASCII"
]
=
False
# jsonify返回的中文正常显示
from
utils.web
import
*
rule_list
=
getRules
()
...
...
@@ -102,6 +102,21 @@ def clear():
os
.
remove
(
cache_path
)
return
jsonify
(
error
.
success
(
'成功删除文件:'
+
cache_path
))
@
app
.
route
(
'/rules'
)
def
rules
():
# base_path = os.path.dirname(os.path.abspath(__file__))+'cache' # 当前文件所在目录
base_path
=
'cache/'
# 当前文件所在目录
print
(
base_path
)
file_name
=
os
.
listdir
(
base_path
)
file_name
=
list
(
filter
(
lambda
x
:
str
(
x
).
endswith
(
'.js'
),
file_name
))
# print(file_name)
rule_list
=
[
file
.
replace
(
'.js'
,
''
)
for
file
in
file_name
]
rules
=
{
'list'
:
rule_list
,
'count'
:
len
(
rule_list
)}
# print(rule_list)
# return jsonify(obj)
return
render_template
(
'rules.html'
,
rules
=
rules
)
if
__name__
==
'__main__'
:
app
.
run
(
host
=
"0.0.0.0"
,
port
=
5705
)
# app.run(debug=True, host='0.0.0.0', port=5705)
\ No newline at end of file
readme.md
浏览文件 @
33224bc7
...
...
@@ -9,7 +9,7 @@
-
[X] 6.增加homeUrl和host参数,以及class_parse参数,可以动态定位分类标签
-
[X] 7.获取二级详情函数增加了线程池的使用
-
[ ] 8.模板自定义filter过滤
-
[
] 9.网页端显示缓存的规则以及提供点击清除缓存操作
-
[
X
] 9.网页端显示缓存的规则以及提供点击清除缓存操作
###### 特性说明
1.
参考了海阔视界dr模板设计思路
2.
参考tv_box的t4项目思路重新设计了cms接口
...
...
static/js/jquery.min.js
0 → 100644
浏览文件 @
33224bc7
此差异已折叠。
点击以展开。
templates/index.html
浏览文件 @
33224bc7
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
charset=
"utf-8"
>
<meta
http-equiv=
"Cache-Control"
content=
"no-siteapp;no-transform"
>
<meta
name=
"applicable-device"
content=
"pc,mobile"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
>
<title>
dr_py首页
</title>
</head>
<body>
<h1>
欢迎使用dr_py项目
</h1>
<p>
可以简单的自定义爬虫实现cms数据接口
</p>
<a
href=
"/clear?rule="
>
缓存清理接口
</a>
<div>
<a
href=
"/clear?rule="
>
缓存清理接口
</a>
</div>
<div>
<a
href=
"/rules"
>
缓存文件列表
</a>
</div>
</body>
</html>
\ No newline at end of file
templates/rules.html
0 → 100644
浏览文件 @
33224bc7
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"utf-8"
>
<meta
http-equiv=
"Cache-Control"
content=
"no-siteapp;no-transform"
>
<meta
name=
"applicable-device"
content=
"pc,mobile"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
>
<title>
已缓存规则列表-{{rules.count}}
</title>
<script
src=
"/static/js/jquery.min.js"
></script>
</head>
<style>
.red
{
color
:
red
;
font-weight
:
bold
}
.yellow
{
color
:
yellow
;
font-weight
:
bold
}
.refresh
{
}
</style>
<body>
<script>
$
(
document
).
ready
(
function
(){
$
(
"
.refresh
"
).
click
(
function
(){
// location.reload();
let
rule
=
this
.
innerText
.
trim
();
let
code
=
$
.
ajax
({
url
:
"
/clear?rule=
"
+
rule
,
async
:
false
}).
responseText
;
code
=
typeof
(
code
)
===
"
object
"
?
code
:
JSON
.
parse
(
code
);
if
(
code
.
code
===
200
){
alert
(
code
.
msg
);
location
.
reload
()
}
});
});
</script>
{% if rules.count
<
1
%}
<
h3
>
暂无已缓存的规则
</h3>
{% endif %}
{% for rule in rules.list %}
{% if rule|length > 2 %}
<!-- | 为过滤条件 -->
<li
class=
"red"
>
<!-- <a class="refresh" href="/clear?rule={{rule}}" target="_blank">{{ rule }}</a>-->
<a
class=
"refresh"
href=
"javascript:void(0);"
>
{{ rule }}
</a>
</li>
{% else %}
<!-- 如果是if条件,最后必须要有else,否则就会报错 -->
<li
class=
"yellow"
>
<a
class=
"refresh"
href=
"javascript:void(0);"
target=
"_blank"
>
{{ rule }}
</a>
</li>
{% endif %}
<!-- if条件必须有endif,否则会报错 -->
{% endfor %}
</body>
</html>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录