python代码示例:
import csv
import execjs
import requests
f = open('精灵数据.csv','w',encoding='utf-8',newline='')
csv_writer = csv.DictWriter(f,fieldnames=[
'标题',
'发布时间',
'新闻来源',
'详情页链接',
'转自',
'点击量',
'新闻作者',
'发布时间小时',
])
csv_writer.writeheader()
data = []
for page in range(1, 51):
url = 'https://vapi.jinglingshuju.com/Data/getNewsList'
payload = {
'page': str(page),
'num': '20',
}
headers = {
'Accept': 'application/json, text/plain, */*',
'Accept-Encoding': 'gzip, deflate, br, zstd',
'Accept-Language': 'zh-CN, zh;q=0.9',
'Content-Type': 'application/x-www-form-urlencoded',
'Origin': 'https://www.jinglingshuju.com',
'Sec-Ch-Ua': '"Not_A_Brand";v="99", "Chromium";v="99", "Google Chrome";v="99"',
'Sec-Ch-Ua-Mobile': '?0',
'Sec-Ch-Ua-Platform': '"Windows"',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-site',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.0.0 Safari/537.36',
}
response = requests.post(url=url, data=payload, headers=headers)
json_data = response.json()['data']
data.append(json_data) #获取所有的密文数据,并存储在data列表中
a = open('练习.js','r',encoding='utf-8').read()
for data in data:
js = execjs.compile(a)
mi_wen = js.call('f',data)
dery_data = js.call('s',mi_wen)
for i in dery_data['list']:
dit={
'标题':i['title'],
'发布时间':i['news_time'],
'新闻来源':i['news_source'],
'详情页链接':i['detail'],
'转自':i['summary'],
'点击量':i['hits'],
'新闻作者':i['news_author'],
'发布时间小时':i['time_str'],
}
print(dit)
csv_writer.writerow(dit)
js代码示例:
const CryptoJs = require('crypto-js');
function f(data){
j = "DXZWdxUZ5jgsUFPF";
z = CryptoJs.enc.Utf8.parse(j)
data1 = CryptoJs.AES.decrypt(data, z,
{
iv: CryptoJs.enc.Utf8.parse(j.substr(0, 16)), mode: CryptoJs.mode.ECB,
padding: CryptoJs.pad.Pkcs7
});
return data1.toString(CryptoJs.enc.Utf8);}
function s(data1){
return JSON.parse(data1);
}
结果展示: