Document the project structure and setup while excluding local dependencies and IDE settings. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
import time
|
|
|
|
import requests
|
|
import execjs
|
|
|
|
headers = {
|
|
"Accept": "application/json, text/plain, */*",
|
|
"Accept-Language": "zh-CN,zh;q=0.9",
|
|
"Connection": "keep-alive",
|
|
"Content-Length": "0",
|
|
"Origin": "https://ec.minmetals.com.cn",
|
|
"Referer": "https://ec.minmetals.com.cn/open/home/purchase-info",
|
|
"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/152.0.0.0 Safari/537.36",
|
|
"sec-ch-ua": "\"Chromium\";v=\"152\", \"Not?A_Brand\";v=\"24\", \"Google Chrome\";v=\"152\"",
|
|
"sec-ch-ua-mobile": "?0",
|
|
"sec-ch-ua-platform": "\"Windows\""
|
|
}
|
|
with open("五矿集团.js", "r", encoding="utf-8") as f:
|
|
code_js = f.read()
|
|
cookies = {
|
|
# "__jsluid_s": "e761c17024077e17ad5b78ccdd2b3df3",
|
|
"SUNWAY-ESCM-COOKIE": "a9a9e461-c1c4-4348-b1f3-60ace80a499e",
|
|
"JSESSIONID": "C1F0A4A6E17FA8D3F9674563DF3F20C9"
|
|
}
|
|
ctx = execjs.compile(code_js)
|
|
|
|
for page in range(1, 6):
|
|
public_key = requests.post("https://ec.minmetals.com.cn/open/homepage/public", headers=headers).text
|
|
|
|
encrypt_params = ctx.call("encrypt_param", public_key, page)
|
|
|
|
json_data = {
|
|
"param": encrypt_params,
|
|
}
|
|
|
|
response = requests.post(
|
|
"https://ec.minmetals.com.cn/open/homepage/zbs/by-lx-page",
|
|
cookies=cookies,
|
|
headers=headers,
|
|
json=json_data
|
|
)
|
|
print(response.json())
|
|
# print(response.text)
|
|
time.sleep(1)
|