当前位置:网站首页>execjs 调用
execjs 调用
2022-07-28 05:25:00 【幻影七幻】
isNotNull = function (obj) {
if (obj === undefined || obj === null || obj == "null" || obj === "" || obj == "undefined")
return false;
return true;
};
function getDecryptedParameters(__signature) {
var sig = "";
var chars = "0123456789abcdef";
if (!isNotNull(__signature)) {
var curTime = parseInt(Math.random() * (9999 - 1000 + 1) + 1000) + "" + Date.parse(new Date());
sig = chars.charAt(parseInt(Math.random() * (15 - 15 + 1) + 10)) + chars.charAt(curTime.length) + "" + curTime;
} else {
sig = __signature;
}
var key = "";
var keyIndex = -1;
for (var i = 0; i < 6; i++) {
var c = sig.charAt(keyIndex + 1);
key += c;
keyIndex = chars.indexOf(c);
if (keyIndex < 0 || keyIndex >= sig.length) {
keyIndex = i;
}
}
var timestamp = parseInt(Math.random() * (9999 - 1000 + 1) + 1000) + "_" + key + "_" + Date.parse(new Date());
var t = timestamp;
//LEx.azdg.encrypt(timestamp,key);
t = t.replace(/\+/g, "_");
return {"s": sig, "t": t};
}
// 测试样例
// console.log(getDecryptedParameters("c988121626057020055"))encrypt.js文件
目标文件http://zwfw.san-he.gov.cn/icity/icity/guestbook/interact
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import re
import execjs
import requests
index_url = 'http://zwfw.san-he.gov.cn/icity/icity/guestbook/interact'
data_url = 'http://zwfw.san-he.gov.cn/icity/api-v2/app.icity.guestbook.WriteCmd/getList'
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'}
session = requests.session()
def get_encrypted_parameters(signature):
with open('encrypt.js', 'r', encoding='utf-8') as f:
zwfw_san_he_js = f.read()
encrypted_parameters = execjs.compile(zwfw_san_he_js).call('getDecryptedParameters', signature)
return encrypted_parameters
def get_signature_and_cookies():
response = session.get(url=index_url, headers=headers)
cookies = response.cookies.get_dict()
cookie = cookies['ICITYSession']
signature = re.findall(r'signature = "(.*)"', response.text)[0]
return cookie, signature
def get_data(cookie, parameters, page):
payload_data = {'start': page*7, 'limit': 7, '[email protected]=': '2', '[email protected]=': '1'}
params = {'s': parameters['s'], 't': parameters['t']}
cookies = {'ICITYSession': cookie}
response = session.post(url=data_url, headers=headers, json=payload_data, params=params, cookies=cookies).json()
print(payload_data, response)
def main():
ck, sig = get_signature_and_cookies()
for page in range(10):
# 采集10页数据
param = get_encrypted_parameters(sig)
get_data(ck, param, page)
if __name__ == '__main__':
main()边栏推荐
- Measure computer battery capacity
- clickhouse聚合之内存不足怎么办?那就提升聚合性能
- Design and analysis of contactor coil control circuit
- 相对路径和绝对路径
- 使用wampserver3.2.6时切换中文时造成启动失败
- Pycharm2019设置编辑器主题和默认代码
- Relative path and absolute path
- PT physical aware based on multi voltage
- Pytorch learning note 4 - automatic calculation of gradient descent autograd
- 保研面试中常见的英语问题有哪些?
猜你喜欢

Bert bidirectional encoder based on transformer

Shuffle Net_ v1-shuffle_ v2

小程序:生命周期

到底什么是Hash?(量化交易机器人系统开发)

VAN(DWConv+DWDilationConv+PWConv)

How to calibrate dsx2-8000? Calibration process?

qt自定义滑动按钮(美观且使用方便)

Systemmediasize startup option added in esxi 7.0 update 1C

How to test industrial Ethernet cables (using fluke dsx-8000)?

Overall understanding of PLC
随机推荐
Measure computer battery capacity
Trouble encountered in cable testing -- a case study of a manufacturer?
qt实现将相关信息输出到日志文件
PyTorch 学习笔记
MATLAB signal processing
qt设置加载界面的几种方法
Esxi on arm 10/22 update
Find the network address and broadcast address of the host according to the IP address and subnet mask
qt解析字符串转为json数据并解析
JSP实现文件上传功能的同时还要向后台传递参数
Pytorch learning notes
Talk about the "hybrid mode" of esxi virtual switch and port group
PyTorch 学习笔记 2 —— About Tensor
qt绘画事件-设置背景图片
Perl入门学习(八)子程序
Filter
In vscade, the source file "adafruit_gfx.h" cannot be opened“
Common table expression CTE in Clickhouse
基于 YOLOV5 的 SAR 图像舰船检测
测量电脑电池容量