From 2008e644116070172f028ef6e39bcc68c82dd521 Mon Sep 17 00:00:00 2001 From: pioxnb2gm <3307645003@qq.com> Date: Sat, 1 Jun 2024 14:59:13 +0800 Subject: [PATCH] ADD file via upload --- get_contend.py | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 get_contend.py diff --git a/get_contend.py b/get_contend.py new file mode 100644 index 0000000..288ccbd --- /dev/null +++ b/get_contend.py @@ -0,0 +1,61 @@ +import requests +import json +from lxml import etree +import js2py +import login +USERNAME="td188310339" +PASSWORD="Aa123456" +COOKIE=login(USERNAME,PASSWORD) +HEADERS={ + 'Cookies':COOKIE +} +BASE_URL='https://www.tadu.com/' +def get_id(num): + text =requests.get(f'{BASE_URL}/book/988681/{num+1}/?isfirstpart=true',headers=HEADERS).text + html=etree.HTML(text) + return html.xpath('//a[@id="paging_left"]/@href')[0].strip().split('/')[-1] +for chapter_num in range (1,101): + js_code = """ + function encipher(e) { + var a = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" + , t = "=" + , o = function(e) { + var o, s = "", i = e.length; + for (o = 0; i - 2 > o; o += 3) + s += a[e.charCodeAt(o) >> 2], + s += a[((3 & e.charCodeAt(o)) << 4) + (e.charCodeAt(o + 1) >> 4)], + s += a[((15 & e.charCodeAt(o + 1)) << 2) + (e.charCodeAt(o + 2) >> 6)], + s += a[63 & e.charCodeAt(o + 2)]; + return i % 3 && (o = i - i % 3, + s += a[e.charCodeAt(o) >> 2], + i % 3 == 2 ? (s += a[((3 & e.charCodeAt(o)) << 4) + (e.charCodeAt(o + 1) >> 4)], + s += a[(15 & e.charCodeAt(o + 1)) << 2], + s += t) : (s += a[(3 & e.charCodeAt(o)) << 4], + s += t + t)), + s + }; + return o(e) + } + """ + encipher = js2py.eval_js(js_code) + + chapter_id = get_id(1) + + dataLimit = encipher(chapter_id) + + print(dataLimit) + + res = requests.get(f'{BASE_URL}getPartContentByCodeTable/988681/{chapter_num},headers=HEADERS)') + + text = res.text + + text = json.loads(text) + + text = text['data']['content'] + + html = etree.HTML(text) + + texts = html.xpath(f'//p[not(constains(@data-limit,"{dataLimit}"))]/text()') + + for txt in texts: + print(txt) \ No newline at end of file