123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- # -*- coding: utf-8 -*-
- """
- Created on 2025-04-09
- ---------
- @summary: 工具
- ---------
- @author: Dzr
- """
- import json
- import random
- import time
- import execjs
- import requests
- def execjs_call(function, param):
- with open('./nmgzbtbggfwpt_js.js', 'r') as f:
- ex_js = f.read()
- ctx = execjs.compile(ex_js)
- return ctx.call(function, param)
- def fetch_data(sid, tender_id, tender_type, tsqymc=None, proxies=None):
- url = "https://www.nmgztb.com.cn/ih5/player/function/run?nid=11057637"
- headers = {
- "authority": "www.nmgztb.com.cn",
- "accept": "*/*",
- "accept-language": "zh-CN,zh;q=0.9",
- "cache-control": "no-cache",
- "content-type": "text/plain;charset=UTF-8",
- "origin": "https://www.nmgztb.com.cn",
- "referer": "https://www.nmgztb.com.cn/?c=article&a=type&tid=3",
- "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"
- }
- data_org = {
- "TenderId": tender_id,
- "TenderType": tender_type,
- "_nid": 11057637,
- "_uid": 10124717,
- "_gid": 17363,
- "_eid": 0,
- "_sid": sid,
- "_locOffset": 28800,
- "_lang": "zh"
- }
- if tsqymc is not None:
- data_org["tsqymc"] = tsqymc
- data = execjs_call('get_temp', data_org)
- res = requests.post(url, headers=headers, data=data, timeout=120, proxies=proxies)
- time.sleep(random.randint(3, 5))
- json_str = execjs_call('de_data', res.content.decode())
- return json.loads(json_str).get('data')
|