Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
pgl99
dr_py
提交
72e11600
dr_py
项目概览
pgl99
/
dr_py
与 Fork 源项目一致
2023-03-02 03:36:06同步失败
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,发现更多精彩内容 >>
提交
72e11600
编写于
8月 27, 2022
作者:
H
hjdhnx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加缓存文件查看接口
上级
4d0c204c
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
107 addition
and
14 deletion
+107
-14
app.py
app.py
+21
-7
pycms.json
pycms.json
+1
-1
pycms2.json
pycms2.json
+1
-1
templates/index.html
templates/index.html
+20
-3
templates/raw.html
templates/raw.html
+61
-0
utils/parser.py
utils/parser.py
+3
-2
未找到文件。
app.py
浏览文件 @
72e11600
...
...
@@ -102,19 +102,33 @@ 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' # 当前文件所在目录
def
getRules
():
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
)
rules
=
{
'list'
:
rule_list
,
'count'
:
len
(
rule_list
)}
return
rules
@
app
.
route
(
'/rules'
)
def
rules
():
return
render_template
(
'rules.html'
,
rules
=
getRules
())
@
app
.
route
(
'/raw'
)
def
rules_raw
():
return
render_template
(
'raw.html'
,
rules
=
getRules
())
@
app
.
route
(
"/plugin/<name>"
,
methods
=
[
'GET'
])
def
plugin
(
name
):
# name=道长影视模板.js
if
not
name
or
not
name
.
split
(
'.'
)[
-
1
]
in
[
'js'
,
'txt'
,
'py'
,
'json'
]:
return
jsonify
(
error
.
failed
(
f
'非法威胁,未指定文件名。必须包含js|txt|json|py'
))
try
:
return
parser
.
toJs
(
name
)
except
Exception
as
e
:
return
jsonify
(
error
.
failed
(
f
'非法猥亵
\n
{
e
}
'
))
if
__name__
==
'__main__'
:
...
...
pycms.json
浏览文件 @
72e11600
...
...
@@ -47,7 +47,7 @@
"key"
:
"dr_ckmv"
,
"name"
:
"cokemv(道长)"
,
"type"
:
1
,
"api"
:
"http://cms.nokia.press/vod?rule=cokemv"
,
"api"
:
"http://cms.nokia.press/vod?rule=cokemv
&ext=https://gitcode.net/qq_32394351/dr_py/-/raw/master/js/cokemv.js
"
,
"searchable"
:
1
,
"quickSearch"
:
1
,
"filterable"
:
1
...
...
pycms2.json
浏览文件 @
72e11600
...
...
@@ -48,7 +48,7 @@
"key"
:
"dr_ckmv"
,
"name"
:
"cokemv(道长)"
,
"type"
:
1
,
"api"
:
"http://localhost:5705/vod?rule=cokemv"
,
"api"
:
"http://localhost:5705/vod?rule=cokemv
&ext=https://gitcode.net/qq_32394351/dr_py/-/raw/master/js/cokemv.js
"
,
"searchable"
:
1
,
"quickSearch"
:
1
,
"filterable"
:
1
...
...
templates/index.html
浏览文件 @
72e11600
...
...
@@ -8,14 +8,31 @@
<meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
>
<title>
dr_py首页
</title>
</head>
<style>
.btn
{
margin-bottom
:
2rem
;
border
:
1px
solid
#F00
;
width
:
180px
;
height
:
30px
;
text-align
:
center
;
background-color
:
#1379cb
;
color
:
#ffffff
;
}
.btn
a
{
color
:
#ffffff
;
}
</style>
<body>
<h1>
欢迎使用dr_py项目
</h1>
<p>
可以简单的自定义爬虫实现cms数据接口
</p>
<div>
<div
class=
"btn"
>
<a
href=
"/clear?rule="
>
缓存清理接口
</a>
</div>
<div>
<a
href=
"/rules"
>
缓存文件列表
</a>
<div
class=
"btn"
>
<a
href=
"/rules"
>
缓存文件列表-清除
</a>
</div>
<div
class=
"btn"
>
<a
href=
"/raw"
>
缓存文件列表-查看
</a>
</div>
</body>
</html>
\ No newline at end of file
templates/raw.html
0 → 100644
浏览文件 @
72e11600
<!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
();
location
.
href
=
'
/plugin/
'
+
rule
+
'
.js
'
;
});
});
</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);"
>
{{ rule }}
</a>
</li>
{% endif %}
<!-- if条件必须有endif,否则会报错 -->
{% endfor %}
</body>
</html>
\ No newline at end of file
utils/parser.py
浏览文件 @
72e11600
...
...
@@ -48,7 +48,8 @@ def runJs(jsPath):
def
toJs
(
jsPath
):
base_path
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
)))
# 上级目录
js_path
=
os
.
path
.
join
(
base_path
,
jsPath
)
js_path
=
os
.
path
.
join
(
base_path
,
f
'cache/
{
jsPath
}
'
)
print
(
js_path
)
if
not
os
.
path
.
exists
(
js_path
):
return
jsonify
({
'code'
:
-
2
,
'msg'
:
f
'非法猥亵,文件不存在'
})
with
open
(
js_path
,
'r'
,
encoding
=
'UTF-8'
)
as
fp
:
...
...
@@ -59,7 +60,7 @@ def toJs(jsPath):
def
toHtml
(
jsPath
):
base_path
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
)))
# 上级目录
js_path
=
os
.
path
.
join
(
base_path
,
jsPath
)
js_path
=
os
.
path
.
join
(
base_path
,
f
'cache/
{
jsPath
}
'
)
with
open
(
js_path
,
'r'
,
encoding
=
'UTF-8'
)
as
fp
:
js
=
fp
.
read
()
response
=
make_response
(
js
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录