From a66ba75ed0dafcc16363f11bd268072bb5f2a38a Mon Sep 17 00:00:00 2001 From: hjdhnx Date: Thu, 25 Aug 2022 15:15:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90cms=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=B0=81=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 13 ++++++ "js/\351\270\255\345\245\210\351\243\236.js" | 2 +- models/cms.py | 47 ++++++++++++++++++-- pycms.json | 2 +- 4 files changed, 58 insertions(+), 6 deletions(-) diff --git a/app.py b/app.py index b885148..32fb42d 100644 --- a/app.py +++ b/app.py @@ -55,6 +55,19 @@ def vod(): cms = CMS(rule) print(cms) print(cms.title) + wd = getParmas('wd') + ac = getParmas('ac') + quick = getParmas('quick') + play = getParmas('play') + flag = getParmas('flag') + filter = getParmas('filter') + t = getParmas('t') + pg = getParmas('pg') + ext = getParmas('ext') + ids = getParmas('ids') + q = getParmas('q') + print(getParmas()) + 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 3886730..8def566 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" @@ -9,5 +9,5 @@ var rule = { class_url:'dianying&lianxuju&zongyi&dongman', 一级:'body a.module-poster-item.module-item;a&&title;.lazyload&&data-original;.module-item-note&&Text;a&&href', 二级:{"title":"h1&&Text;.module-info-tag&&Text","img":".lazyload&&data-original","desc":".module-info-item:eq(1)&&Text;.module-info-item:eq(2)&&Text;.module-info-item:eq(3)&&Text","content":".module-info-introduction&&Text","tabs":".module-tab-item","lists":".module-play-list:eq(#id) a"}, - 搜索:'', + 搜索:'body .module-item;.module-card-item-title&&Text;.lazyload&&data-original;.module-item-note&&Text;a&&href;.module-info-item-content&&Text', } \ No newline at end of file diff --git a/models/cms.py b/models/cms.py index b175f77..1851632 100644 --- a/models/cms.py +++ b/models/cms.py @@ -8,6 +8,7 @@ import requests from utils.web import * from utils.config import config from utils.htmlParser import jsoup +from urllib.parse import urljoin class CMS: def __init__(self,rule): @@ -92,8 +93,8 @@ class CMS: # params = '-'.join(urlParams) # print(params) # url = self.url + '/{0}.html'.format(params) - fypage = str(fypage) - url = self.url.replace('fyclass',fyclass).replace('fypage',fypage) + pg = str(fypage) + url = self.url.replace('fyclass',fyclass).replace('fypage',pg) print(url) headers = {'user-agent': self.ua} r = requests.get(url, headers=headers) @@ -113,7 +114,7 @@ class CMS: img = pd(item, p[2]) desc = pdfh(item, p[3]) link = pd(item, p[4]) - content = '' + content = '' if len(p) < 6 else pdfh(item, p[5]) # sid = self.regStr(sid, "/video/(\\S+).html") videos.append({ "vod_id": link, @@ -218,6 +219,43 @@ class CMS: } return result + def searchContent(self, key, fypage=1,quick=1): + pg = str(fypage) + url = self.searchUrl.replace('**', key).replace('fypage',pg) + if not str(url).startswith('http'): + url = urljoin(self.url,url) + print(url) + headers = {'user-agent': self.ua} + r = requests.get(url, headers=headers) + html = r.text + p = self.搜索.split(';') # 解析 + jsp = jsoup(self.url) + pdfh = jsp.pdfh + pdfa = jsp.pdfa + pd = jsp.pd + pq = jsp.pq + items = pdfa(html, p[0]) + videos = [] + for item in items: + # print(item) + title = pdfh(item, p[1]) + img = pd(item, p[2]) + desc = pdfh(item, p[3]) + link = pd(item, p[4]) + content = '' if len(p) < 6 else pdfh(item, p[5]) + # sid = self.regStr(sid, "/video/(\\S+).html") + videos.append({ + "vod_id": link, + "vod_name": title, + "vod_pic": img, + "vod_remarks": desc, + "vod_content": content, + }) + result = { + 'list': videos + } + return result + if __name__ == '__main__': from utils import parser js_path = f'js/鸭奈飞.js' @@ -227,4 +265,5 @@ if __name__ == '__main__': print(cms.title) # print(cms.homeContent()) # cms.categoryContent('dianying',1) - print(cms.detailContent(['67391'])) \ No newline at end of file + # print(cms.detailContent(['67391'])) + print(cms.searchContent('斗罗大陆')) \ No newline at end of file diff --git a/pycms.json b/pycms.json index ed7e23c..1129b5e 100644 --- a/pycms.json +++ b/pycms.json @@ -2,7 +2,7 @@ "key":"dr_yanaifei", "name":"鸭奈飞", "type":4, - "api":"http://127.0.0.1:9000/vod?rule=鸭奈飞", + "api":"http://192.168.10.99:9000/vod?rule=鸭奈飞", "searchable": 1, "quickSearch": 1, "filterable": 1 -- GitLab