from Crypto.Cipher import DES
from Crypto.Util.Padding import unpad
import base64
import requests
import json
import urllib3
# 禁用 InsecureRequestWarning
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
def des_decrypt(encrypted_data):
key = b'IFROMC86' # DES 密钥为 8 字节
encrypted_data_bytes = base64.b64decode(encrypted_data) # 将 base64 编码的数据解码为字节
cipher = DES.new(key, DES.MODE_ECB) # 创建 DES 解密器,使用 ECB 模式
decrypted_data_bytes = cipher.decrypt(encrypted_data_bytes) # 解密数据
decrypted_data_bytes_unpadded = unpad(decrypted_data_bytes, DES.block_size) # 移除 PKCS7 填充
decrypted_data_str = decrypted_data_bytes_unpadded.decode('utf-8') # 将解密后的字节转换为字符串
return json.loads(decrypted_data_str) # 解析 JSON 数据并返回
def get_data_info():
headers = {
"Accept": "application/json, text/plain, */*",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
"Authorization": "Bearer undefined",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"Content-Type": "application/json;charset=UTF-8",
"Origin": "https://kd.nsfc.cn",
"Pragma": "no-cache",
"Referer": "https://kd.nsfc.cn/finalSearchList?s=%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-origin",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 Edg/121.0.0.0",
"sec-ch-ua": "\"Not A(Brand\";v=\"99\", \"Microsoft Edge\";v=\"121\", \"Chromium\";v=\"121\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"Windows\""
}
url = "https://kd.nsfc.cn/api/baseQuery/completionQueryResultsData"
data = {
"code": "F02",
"fuzzyKeyword": "",
"complete": True,
"isFuzzySearch": False,
"conclusionYear": "2018",
"dependUnit": "",
"keywords": "",
"pageNum": 2,
"pageSize": 10,
"personInCharge": "",
"projectName": "",
"projectType": "218",
"subPType": "",
"psPType": "",
"ratifyNo": "",
"ratifyYear": "",
"order": "enddate",
"ordering": "desc",
"codeScreening": "",
"dependUnitScreening": "",
"keywordsScreening": "",
"projectTypeNameScreening": ""
}
data = json.dumps(data, separators=(',', ':'))
response = requests.post(url, headers=headers, data=data, verify=False)
return response.text
# 示例代码注释掉了加密数据部分。加密数据通常是一个很长的字符串,包含多种字符
长方体瞬间转移师
- 粉丝: 49
- 资源: 7
最新资源
- python-leetcode题解之166-Fraction-to-Recurring-Decimal.py
- python-leetcode题解之165-Compare-Version-Numbers.py
- python-leetcode题解之163-Missing-Ranges.py
- python-leetcode题解之162-Find-Peak-Element.py
- python-leetcode题解之161-One-Edit-Distance.py
- python-leetcode题解之160-Intersection-of-Two-Linked-Lists.py
- python-leetcode题解之157-Read-N-Characters-Given-Read4.py
- python-leetcode题解之156-Binary-Tree-Upside-Down.py
- python-leetcode题解之155-Min-Stack.py
- python-leetcode题解之154-Find-Minimum-in-Rotated-Sorted-Array-II.py
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈