这是我的页面头部

noi数据分析工具

import base64
import json
import requests
import time
arr = ['戚朗瑞','王相文']


headers= {
    "accept": "*/*",
    "accept-language": "zh-CN,zh;q=0.9",
    "cache-control": "no-cache",
    "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
    "Origin": "https://www.noi.cn",
    "pragma": "no-cache",
    "sec-ch-ua": "\"Not.A/Brand\";v=\"8\", \"Chromium\";v=\"114\", \"Google Chrome\";v=\"114\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Windows\"",
    "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/114.0.0.0 Safari/537.36",
    "x-requested-with": "XMLHttpRequest",
    "referrer": "https://www.noi.cn/hjmd/mdcx/",
    "referrerPolicy": "strict-origin-when-cross-origin"
}
a= open( './abc.txt',"w" ) 
tableheader =['ID', 'CatalogInnerCode', 'ContestName', 'CertificateNum', 'Name', 'Gender', 'IDCard', 'Teachers', 'Province', 'School', 'Grade', 'Score', 'Awards', 'Prop1', 'Prop2', 'Prop3', 'Prop4', 'AddUser', 'AddTime', 'ModifyUser', 'ModifyTime', 'GenderName']
strheader = "\t".join( tableheader)
a.write( strheader )
for babyname in  arr:
    if len(babyname) <2:
        continue
    stra = '{"Name":"' +babyname + '"}'
    strb = base64.urlsafe_b64encode( stra.encode() ).decode().replace("=","")
    print (stra + '\t' + strb + '\n')
    data2 = '_ZVING_METHOD=awardListFront.search&_ZVING_URL=/hjmd/mdcx/&_ZVING_DATA=' + strb+ '&_ZVING_DATA_FORMAT=json'
    resp = requests.post('https://www.noi.cn/ccf/ajax/invoke',data = data2, headers = headers)
    recs =json.loads( json.loads(resp.text)['data'].encode())
    keys = json.loads(recs[0]).keys()        
    strkey = "\t".join( keys)
    print( strkey )
    for rec in recs: 
        value= list(map(lambda x:repr(x),json.loads(rec).values())).copy()
        strvalue = "\t".join( value)
        print( strvalue )
        a.write( strvalue +'\n' )
    time.sleep(1)
   # print ( str.text .decode
a.close()

 

posted @ 2023-07-13 09:00  范晨鹏  阅读(30)  评论(0编辑  收藏  举报