提交 1095955d 编写于 作者: H hjdhnx

我又可以了,js免嗅肝出来了

上级 55b1ec5a
...@@ -11,6 +11,7 @@ from utils.web import * ...@@ -11,6 +11,7 @@ from utils.web import *
from models import * from models import *
from utils.config import config from utils.config import config
from utils.log import logger from utils.log import logger
from utils.encode import base64Encode,baseDecode,fetch,post
from utils.safePython import safePython from utils.safePython import safePython
from utils.parser import runPy,runJScode from utils.parser import runPy,runJScode
from utils.htmlParser import jsoup from utils.htmlParser import jsoup
...@@ -19,6 +20,11 @@ from concurrent.futures import ThreadPoolExecutor # 引入线程池 ...@@ -19,6 +20,11 @@ from concurrent.futures import ThreadPoolExecutor # 引入线程池
from flask import url_for,redirect from flask import url_for,redirect
from easydict import EasyDict as edict from easydict import EasyDict as edict
py_ctx = {
'requests':requests,'print':print,'base64Encode':base64Encode,'baseDecode':baseDecode,
'log':logger.info,'fetch':fetch,'post':post
}
class CMS: class CMS:
def __init__(self, rule, db=None, RuleClass=None, PlayParse=None,new_conf=None): def __init__(self, rule, db=None, RuleClass=None, PlayParse=None,new_conf=None):
if new_conf is None: if new_conf is None:
...@@ -223,7 +229,7 @@ class CMS: ...@@ -223,7 +229,7 @@ class CMS:
logger.info(f"{name}使用缓存播放地址:{real_url}") logger.info(f"{name}使用缓存播放地址:{real_url}")
return real_url return real_url
else: else:
return [] return ''
def saveParse(self, play_url,real_url): def saveParse(self, play_url,real_url):
if not self.db: if not self.db:
...@@ -632,11 +638,14 @@ class CMS: ...@@ -632,11 +638,14 @@ class CMS:
jscode = str(self.lazy).split('js:')[1] jscode = str(self.lazy).split('js:')[1]
# jscode = f'var input={play_url};{jscode}' # jscode = f'var input={play_url};{jscode}'
# print(jscode) # print(jscode)
loader,_ = runJScode(jscode,ctx={'input':play_url, py_ctx.update({
'requests':requests,'print':print,'d':self.d, 'input': play_url,
'log':logger.info,'pdfh':self.d.jsp.pdfh, 'd': self.d,
'pdfa': self.d.jsp.pdfa,'pd':self.d.jsp.pd, 'pdfh': self.d.jsp.pdfh,
}) 'pdfa': self.d.jsp.pdfa, 'pd': self.d.jsp.pd,
})
ctx = py_ctx
loader,_ = runJScode(jscode,ctx=ctx)
# print(loader.toString()) # print(loader.toString())
play_url = loader.eval('input') play_url = loader.eval('input')
print('play_url:',play_url) print('play_url:',play_url)
......
...@@ -13,7 +13,8 @@ var rule = { ...@@ -13,7 +13,8 @@ var rule = {
play_parse:true, play_parse:true,
// lazy:'干饭', // lazy:'干饭',
// lazy:'@js:cacheUrl = d.getParse(input);print(cacheUrl);input=cacheUrl', // lazy:'@js:cacheUrl = d.getParse(input);print(cacheUrl);input=cacheUrl',
lazy:'js:cacheUrl = d.getParse(input);print(cacheUrl);input=cacheUrl', // lazy:'js:cacheUrl = d.getParse(input);print(cacheUrl);input=cacheUrl',
lazy:'js:cacheUrl=d.getParse(input);if(cacheUrl){input=cacheUrl}else{try{let html=fetch(input,{headers:d.headers,timeout:d.timeout,encoding:d.encoding});let ret=html.match(/var player_(.*?)=(.*?)</)[2];let url=JSON.parse(ret).url;if(url.length>10){real_url="https://player.buyaotou.xyz/?url="+url;d.saveParse(input,real_url);input=real_url}}catch(e){print("网络请求发生错误:"+e.message)}}',
limit:5, limit:5,
推荐:'ul.stui-vodlist.clearfix;li;a&&title;.lazyload&&data-original;;a&&href', 推荐:'ul.stui-vodlist.clearfix;li;a&&title;.lazyload&&data-original;;a&&href',
double:true, // 推荐内容是否双层定位 double:true, // 推荐内容是否双层定位
......
无法预览此类型文件
js: js:
cacheUrl = d.getParse(input); cacheUrl = d.getParse(input);
print(cacheUrl); // print(cacheUrl);
if(cacheUrl){ if(cacheUrl){
input=cacheUrl; input=cacheUrl;
}else{ }else{
try { try {
r = requests.get(input, headers=d.headers,timeout=d.timeout); // let html = fetch([input, {headers:d.headers,timeout:d.timeout,encoding:d.encoding}]);
r.encoding = d.encoding; let html = fetch(input, {headers:d.headers,timeout:d.timeout,encoding:d.encoding});
html = r.text; // js = pdfh(html,'.stui-player__video script:eq(0)&&Html');
// print(js);
let ret = html.match(/var player_(.*?)=(.*?)</)[2]; let ret = html.match(/var player_(.*?)=(.*?)</)[2];
let url = JSON.parse(ret).url; let url = JSON.parse(ret).url;
if(/\.m3u8|\.mp4/.test(url)){ if(url.length > 10){
input = url real_url = 'https://player.buyaotou.xyz/?url='+url;
}else if(!/http/.test(url)&&!/\//.test(url)){ d.saveParse(input,real_url);
try { input = real_url;
url = unescape(base64Decode(url));
if(/http/.test(url)){
input = url
}
}catch (e) {
print('解码url发生错误:'+e.message);
}
} }
}catch (e) { }catch (e) {
print('发生错误:'+e.message); print('网络请求发生错误:'+e.message);
} }
} }
\ No newline at end of file
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
###### 2022/08/29 ###### 2022/08/29
- [X] 1.更换js引擎,速度更快性能更好 - [X] 1.更换js引擎,速度更快性能更好
- [X] 2.新版js支持与python互动,后期可能支持js免嗅(lazy:'@js:xxx') - [X] 2.新版js支持与python互动,后期可能支持js免嗅(lazy:'@js:xxx')
- [X] 3.支持了js免嗅和常用的fetch,post方法
###### 2022/08/28 ###### 2022/08/28
- [X] 1.增加linux进程启动,命令 supervisord -c manager.conf - [X] 1.增加linux进程启动,命令 supervisord -c manager.conf
- [X] 2.转移文本文件到txt目录 - [X] 2.转移文本文件到txt目录
......
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# File : encode.py
# Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------
# Date : 2022/8/29
import base64
import requests
def base64Encode(text):
return base64.b64encode(text.encode("utf8")).decode("utf-8") #base64编码
def baseDecode(text):
return base64.b64decode(text).decode("utf-8") #base64解码
def base_request(url,obj,method='get'):
url = str(url).replace("'", "")
encoding = obj.get('encoding') or 'utf-8'
encoding = str(encoding).replace("'", "")
# print(type(url),url)
# headers = dict(obj.get('headers')) if obj.get('headers') else {}
# headers = obj.get('headers').to_dict() if obj.get('headers') else {}
headers = obj.get('headers') if obj.get('headers') else {}
new_headers = {}
# print(type(headers),headers)
for i in headers:
new_headers[str(i).replace("'", "")] = str(headers[i]).replace("'", "")
# print(type(new_headers), new_headers)
timeout = float(obj.get('timeout').to_int()) if obj.get('timeout') else None
# print(type(timeout), timeout)
body = obj.get('body') if obj.get('body') else {}
new_body = {}
for i in body:
new_body[str(i).replace("'", "")] = str(body[i]).replace("'", "")
# print(type(new_body), new_body)
try:
# r = requests.get(url, headers=headers, params=body, timeout=timeout)
if method.lower() == 'get':
r = requests.get(url, headers=new_headers, params=new_body, timeout=timeout)
else:
r = requests.post(url, headers=new_headers, data=new_body, timeout=timeout)
# r = requests.get(url, timeout=timeout)
# r = requests.get(url)
# print(encoding)
r.encoding = encoding
# print(f'源码:{r.text}')
return r.text
except Exception as e:
print(f'{method}请求发生错误:{e}')
return ''
def fetch(url,obj):
return base_request(url,obj)
def post(url,obj):
return base_request(url,obj,'post')
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册