提交 bb8db294 编写于 作者: H hjdhnx

增加读取配置

上级 f5ade05d
......@@ -9,17 +9,12 @@ from js.rules import rule_list
from utils import error,parser
import sys
import codecs
from models.cms import CMS
sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach())
app = Flask(__name__)
app.config["JSON_AS_ASCII"] = False # jsonify返回的中文正常显示
MOBILE_UA = 'Mozilla/5.0 (Linux; Android 11; M2007J3SC Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045714 Mobile Safari/537.36'
PC_UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36'
UA = 'Mozilla/5.0'
headers = {
'Referer': 'https://www.baidu.com',
'user-agent': UA,
}
from utils.web import *
def getParmas(key=None):
"""
......@@ -54,13 +49,12 @@ def vod():
msg = f'仅支持以下规则:{",".join(rule_list)}'
return jsonify(error.failed(msg))
# with open(f'js/{rule}.js',mode='r',encoding='utf-8') as f:
# js_code = f.read()
js_path = f'js/{rule}.js'
ctx,js_code = parser.runJs(js_path)
a = ctx.eval('rule')
print(a)
print(type(a))
rule = ctx.eval('rule')
cms = CMS(rule)
print(cms)
print(cms.title)
return jsonify({'rule':rule,'js_code':js_code})
if __name__ == '__main__':
......
var rule = {
title:'鸭奈飞',
url:'https://yanetflix.com/vodshow/dianying--------fypage---.html',
searchUrl:'/vodsearch/**----------fypage---.html',
ua:'MOBILE_UA',
......
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# File : __init__.py.py
# Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------
# Date : 2022/8/25
from . import cms
\ No newline at end of file
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# File : cms.py
# Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------
# Date : 2022/8/25
from utils.web import *
class CMS:
def __init__(self,rule):
self.url = rule.get('url','')
self.searchUrl = rule.get('searchUrl','')
ua = rule.get('ua','')
if ua == 'MOBILE_UA':
self.ua = MOBILE_UA
elif ua == 'PC_UA':
self.ua = PC_UA
else:
self.ua = UA
self.searchUrl = rule.get('searchUrl','')
self.class_name = rule.get('class_name','')
self.class_url = rule.get('class_url','')
self.一级 = rule.get('一级','')
self.二级 = rule.get('二级','')
self.搜索 = rule.get('搜索','')
self.title = rule.get('title','')
def getName(self):
return self.title
if __name__ == '__main__':
from utils import parser
js_path = f'js/鸭奈飞.js'
ctx, js_code = parser.runJs(js_path)
rule = ctx.eval('rule')
cms = CMS(rule)
print(cms.title)
\ No newline at end of file
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# File : web.py
# Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------
# Date : 2022/8/25
MOBILE_UA = 'Mozilla/5.0 (Linux; Android 11; M2007J3SC Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045714 Mobile Safari/537.36'
PC_UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36'
UA = 'Mozilla/5.0'
headers = {
'Referer': 'https://www.baidu.com',
'user-agent': UA,
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册