爬虫js基础10
娱乐指数AES加密
const Crypto = require('C://Users/lenovo/AppData/Roaming/npm/node_modules/crypto-js')
function ls(text,lastTime){
var i = Crypto.enc.Utf8.parse(lastTime + "000")
, a = Crypto.enc.Utf8.parse(lastTime + "000")
, s = Crypto.AES.decrypt(text.toString(), i, {
iv: a
}).toString(Crypto.enc.Utf8)
return JSON.parse(s)
}
// function maji(t) {
// var e = Crypto.enc.Utf8.parse("1qaz@wsx3e")
// , i = Crypto.DES.decrypt({
// ciphertext: Crypto.enc.Base64.parse(t)
// }, e, {
// mode: Crypto.mode.ECB,
// padding: Crypto.pad.Pkcs7
// });
// return i.toString(Crypto.enc.Utf8)
// }
//https://www.chinaindex.net/ranklist/4
import requests
import execjs
headers = {
'authority': 'www.chinaindex.net',
'accept': 'application/json, text/plain, */*',
'accept-language': 'zh-CN,zh;q=0.9',
'cookie': 'JSESSIONID=266139E5A8E8DAA37B6088D7CA6AB178; Hm_lvt_2873e2b0bdd5404c734992cd3ae7253f=1689217102; mobile_iindex_uuid=329ed4c0-0264-5a13-a369-f97c245f857f; mobile_username=182****2330; mobile_iindex_token=RtgHPDIrzdkVDPWARLaiXA%3D%3D; Hm_lpvt_2873e2b0bdd5404c734992cd3ae7253f=1689217310',
'funcid': 'undefined',
'incognitomode': '0',
'referer': 'https://www.chinaindex.net/ranklist/4',
'sec-ch-ua': '"Not.A/Brand";v="8", "Chromium";v="114", "Google Chrome";v="114"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-origin',
'token': 'RtgHPDIrzdkVDPWARLaiXA==',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36',
'uuid': '329ed4c0-0264-5a13-a369-f97c245f857f',
}
params = (
('channel', 'movielist'),
('sign', '5f3cce6a40c09a221b21104cc98436a3'),
)
response = requests.get('https://www.chinaindex.net/iIndexMobileServer/mobile/movie/objectFansRank', headers=headers, params=params).json()
te = response['data']
ti = response['lastFetchTime']
ext = execjs.compile(open('./娱乐指数AES加密.js','r',encoding='utf-8').read()).call('ls',te,ti)
print(ext)
#NB. Original query string below. It seems impossible to parse and
#reproduce query strings 100% accurately so the one below is given
#in case the reproduced version is not "correct".
# response = requests.get('https://www.chinaindex.net/iIndexMobileServer/mobile/movie/objectFansRank?channel=movielist&sign=5f3cce6a40c09a221b21104cc98436a3', headers=headers)