提交 a66ba75e 编写于 作者: H hjdhnx

完成cms搜索数据封装

上级 35c816d4
......@@ -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__':
......
......@@ -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
......@@ -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
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册