From 92aa7edac42caeb044a0bba5a80574c1cf0726e8 Mon Sep 17 00:00:00 2001 From: liyf Date: Tue, 20 Dec 2022 17:38:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BA=E6=9C=80=E5=90=8E?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=8E:=202023-03-28=20=E9=98=BF=E9=87=8C?= =?UTF-8?q?=E6=96=87=E5=AD=A6=E5=B0=8F=E8=AF=B4=E7=BD=91=EF=BC=8C=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E6=95=B0=E6=8D=AE=E8=A7=A3=E5=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aliwx/__init__.py | 4 ++ aliwx/demo.py | 107 ++++++++++++++++++++++++++++++++++++++++++++++ readme.MD | 1 + 3 files changed, 112 insertions(+) create mode 100644 aliwx/__init__.py create mode 100644 aliwx/demo.py diff --git a/aliwx/__init__.py b/aliwx/__init__.py new file mode 100644 index 0000000..3af8831 --- /dev/null +++ b/aliwx/__init__.py @@ -0,0 +1,4 @@ +# _*_ coding: utf-8 _*_ +# @Date: 5:34 下午 +# @File: __init__.py.py +# @Author: liyf diff --git a/aliwx/demo.py b/aliwx/demo.py new file mode 100644 index 0000000..2895354 --- /dev/null +++ b/aliwx/demo.py @@ -0,0 +1,107 @@ +# _*_ coding: utf-8 _*_ +# @Date: 4:33 下午 +# @File: demo.py +# @Author: liyf + +import re +import execjs +import requests + +from loguru import logger + +headers = { + 'authority': 'www.aliwx.com.cn', + 'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', + 'accept-language': 'zh-CN,zh;q=0.9', + 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36', +} + + +def get_html(): + params = { + 'bid': '6813923', + 'cid': '674259', + } + response = requests.get('https://www.aliwx.com.cn/reader', params=params, headers=headers) + return response.text + + +def get_decrypt_data(encrypt_data): + js_str = ''' + function _decodeCont(t) { + return t = function (t) { + return t.split("").map(function (t) { + var e, i; + return t.match(/[A-Za-z]/) ? (e = Math.floor(t.charCodeAt(0) / 97), + i = (t.toLowerCase().charCodeAt(0) - 83) % 26 || 26, + String.fromCharCode(i + (0 == e ? 64 : 96))) : t + }).join("") + }(t), + function (t) { + var e, i, a, n, r, c, o, s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", d = "", + l = 0; + for (t = t.replace(/[^A-Za-z0-9\+\/\=]/g, ""); l < t.length;) + n = s.indexOf(t.charAt(l++)), + r = s.indexOf(t.charAt(l++)), + c = s.indexOf(t.charAt(l++)), + o = s.indexOf(t.charAt(l++)), + e = n << 2 | r >> 4, + i = (15 & r) << 4 | c >> 2, + a = (3 & c) << 6 | o, + d += String.fromCharCode(e), + 64 != c && (d += String.fromCharCode(i)), + 64 != o && (d += String.fromCharCode(a)); + return function (t) { + for (var e, i = "", a = 0, n = 0, r = 0; a < t.length;) + n = t.charCodeAt(a), + n < 128 ? (i += String.fromCharCode(n), + a++) : n > 191 && n < 224 ? (r = t.charCodeAt(a + 1), + i += String.fromCharCode((31 & n) << 6 | 63 & r), + a += 2) : (r = t.charCodeAt(a + 1), + e = t.charCodeAt(a + 2), + i += String.fromCharCode((15 & n) << 12 | (63 & r) << 6 | 63 & e), + a += 3); + return i + }(d) + }(t) + } + ''' + ctx = execjs.compile(''.join(js_str)) + decrypt_data = ctx.call('_decodeCont', encrypt_data) + return decrypt_data + + +def get_info(): + html = get_html() + a_str = re.findall(re.compile(r'dataChapters">(.*?)', re.S), html)[0] + data_info = str(a_str).replace('"', '"').replace('true', 'True').replace('false', 'False').replace('amp;', '') + item = eval(data_info) # 字符串转字典 + data_list = item['chapterList'] + info = { + volumedata['volumeName']: { + # 判断是否为收费章节的条件为 isFreeRead 字段 + chapterdata['chapterName']: chapterdata['contUrlSuffix'] if chapterdata['isFreeRead'] else None + for chapterdata in volumedata['volumeList'] + } + for volumedata in data_list + } + return info + + +def get_encrypt_data(): + info = get_info() + for volumeName, item in info.items(): + for chapterName, url_suffix in item.items(): + if url_suffix: + logger.info(f'当前进度: {volumeName}, {chapterName}') + url = f'https://c13.shuqireader.com/pcapi/chapter/contentfree/{url_suffix}' + results = requests.get(url, headers=headers).json() + encrypt_data = results['ChapterContent'] + logger.warning('\n'.join(get_decrypt_data(encrypt_data).split('
'))) + else: + logger.error(f'收费章节: {volumeName}, {chapterName}') + break + + +if __name__ == '__main__': + get_encrypt_data() diff --git a/readme.MD b/readme.MD index 43a2796..db6faab 100644 --- a/readme.MD +++ b/readme.MD @@ -104,6 +104,7 @@ MyToken | [链接](https://www.mytokencap.com/) | [点击跳转](https://blog 搜狐详情页图片地址解密 | [链接](https://www.sohu.com/a/611710835_123753) | [点击跳转](souhu/demo.js) | [souhu](souhu) 黑猫投诉 | [链接](https://tousu.sina.com.cn/company/view/?couid=6384912431) | | [tousu_sign](tousu_sign) 猎聘 | [链接](https://www.liepin.com/zhaopin/?inputFrom=www_index&workYearCode=0&key=&scene=input&ckId=cei1lxwcgvjwp0v613z0tdqvn0ziea1b&dq=) | [点击跳转](liepin/demo.js) | [liepin](liepin) +阿里文学 | [链接](https://www.aliwx.com.cn/reader?bid=6813923&cid=674174) | | [aliwx](aliwx) ***