当前位置:网站首页>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()边栏推荐
猜你喜欢

【服务器使用记录】通过跳板机登录远程服务器并进行文件传输

How many columns are the most suitable for Clickhouse to build a width table?

Fluke dtx-1800 and its accessories dtx-cha002 channel adapter channel replacement RJ45 socket notes
![[server usage record] log in to the remote server through the springboard machine and transfer files](/img/11/1ca6c2f34d43dfb6d766ec0dc3371d.png)
[server usage record] log in to the remote server through the springboard machine and transfer files

Bert bidirectional encoder based on transformer

ConNeXt

OpenGL快速配置方法

MFC 使用控制台打印程序信息

Ship detection in SAR image based on yolov5

Beginners choose sensors
随机推荐
新的selenium
EfficientNET_ V1
qt解析字符串转为json数据并解析
Hugging face 的入门使用
Trouble encountered in cable testing -- a case study of a manufacturer?
Measure computer battery capacity
Vscode中,无法打开源文件 “Adafruit_GFX.h“
Esxi on arm 10/22 update
The startup fails when switching Chinese when using wampserver3.2.6
Matlab simulation of radar imaging 2 - pulse compression and windowing
Selection of PLC
mixup_ ratio
使用wampserver3.2.6时切换中文时造成启动失败
JSP should pass parameters to the background while realizing the file upload function
[server usage record] log in to the remote server through the springboard machine and transfer files
Analysis of MOSFET damage at the moment of power failure of isolated power supply
论文神器 VS Code + LaTex + LaTex Workshop
How many columns are the most suitable for Clickhouse to build a width table?
USB network native driver for esxi updated to support esxi7.0 Update 2
Esxi on ARM v1.2 (updated in November 2020)