From bb8db29407575ceceb5ad8cdf77dcd95a8204c73 Mon Sep 17 00:00:00 2001 From: hjdhnx Date: Thu, 25 Aug 2022 11:06:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AF=BB=E5=8F=96=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 18 ++++------ "js/\351\270\255\345\245\210\351\243\236.js" | 1 + models/__init__.py | 7 ++++ models/cms.py | 36 ++++++++++++++++++++ utils/web.py | 13 +++++++ 5 files changed, 63 insertions(+), 12 deletions(-) create mode 100644 models/__init__.py create mode 100644 models/cms.py create mode 100644 utils/web.py diff --git a/app.py b/app.py index 38f9cfc..b885148 100644 --- a/app.py +++ b/app.py @@ -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__': diff --git "a/js/\351\270\255\345\245\210\351\243\236.js" "b/js/\351\270\255\345\245\210\351\243\236.js" index f03244e..aa38691 100644 --- "a/js/\351\270\255\345\245\210\351\243\236.js" +++ "b/js/\351\270\255\345\245\210\351\243\236.js" @@ -1,4 +1,5 @@ var rule = { + title:'鸭奈飞', url:'https://yanetflix.com/vodshow/dianying--------fypage---.html', searchUrl:'/vodsearch/**----------fypage---.html', ua:'MOBILE_UA', diff --git a/models/__init__.py b/models/__init__.py new file mode 100644 index 0000000..2daf85f --- /dev/null +++ b/models/__init__.py @@ -0,0 +1,7 @@ +#!/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 diff --git a/models/cms.py b/models/cms.py new file mode 100644 index 0000000..e5798c9 --- /dev/null +++ b/models/cms.py @@ -0,0 +1,36 @@ +#!/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 diff --git a/utils/web.py b/utils/web.py new file mode 100644 index 0000000..dbe5425 --- /dev/null +++ b/utils/web.py @@ -0,0 +1,13 @@ +#!/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, +} -- GitLab