import json, subprocess, os BASE='https://minke8.cn' scales=[ ("jlz","贝克焦虑测试量表(BAI)","焦虑症测试"), ("jl2","汉密尔顿焦虑量表(HAMA)","焦虑症测试"), ("jl3","状态-特质焦虑问卷(STAI)","焦虑症测试"), ("jl5","焦虑症筛查量表(GAD-7)","焦虑症测试"), ("jl6","考试焦虑量表(TAS)","焦虑症测试"), ("jl8","中学生焦虑自评量表","焦虑症测试"), ("qp1","耶鲁布朗强迫标准量表(YBOCS)","强迫症测试"), ("qp3","强迫信念问卷(OBQ-44)","强迫症测试"), ("qp4","强迫量表修订版(OCI-R)","强迫症测试"), ("zk1","贝克-拉范森躁狂量表(BRMS)","躁狂症测试"), ("zk2","轻躁狂自评量表(HCL-32)","躁狂症测试"), ("zk3","杨氏躁狂评定量表(YMRS)","躁狂症测试"), ("sx1","心境障碍问卷(MDQ)","双向情感障碍"), ("sx2","双相情感障碍自评量表(BSQ)","双向情感障碍"), ("sk3","交往焦虑量表(IAS)","恐惧症测试"), ("sk4","社交回避及苦恼量表(SAD)","恐惧症测试"), ("sk5","社交焦虑量表(SIAS)","恐惧症测试"), ("sk6","社交恐惧量表(SPS)","恐惧症测试"), ("iq2","瑞文智商测试(60题)","智商测试"), ("iq3","智力测试(增强版)","智商测试"), ("eq1","情商测试量表(BARON)","情商测试"), ("eq2","情绪智力量表(EIS)","情商测试"), ("sm2","匹兹堡睡眠质量指数(PSQI)","其它测试"), ("sm1","阿森斯失眠量表(AIS)","其它测试"), ("qt1","躯体化症状自评量表(SSS)","其它测试"), ("gd6","创伤后应激障碍量表(PCL-C)","其它测试"), ("xl13","防御方式自评量表(DSQ)","其它测试"), ("gd4","家庭环境量表(FES)","其它测试"), ("gd1","婚姻质量问卷(ENRICH)","其它测试"), ("gd2","爱情态度测试(LAS)","其它测试"), ("gd3","心理压力测试(PSTR)","其它测试"), ] results=[] for idx,(slug,name,cat) in enumerate(scales): url=f'{BASE}/{slug}.html' print(f'[{idx+1}/{len(scales)}] {name}', flush=True) try: r=subprocess.run(f'curl -sL -X POST {url} -d action=process\&index=0', shell=True, capture_output=True, text=True, timeout=15) d=json.loads(r.stdout) qc=d.get('length',0) if qc==0: print(f' SKIP (0 q)'); continue except: print(f' FAIL init'); continue qs=[]; os_=[] for i in range(qc): try: r=subprocess.run(f'curl -sL -X POST {url} -d action=process\&index={i}', shell=True, capture_output=True, text=True, timeout=10) d=json.loads(r.stdout) qs.append(d.get('tm','')) os_.append(d.get('xx',[])) except: qs.append(''); os_.append([]) if i%30==29: print('.', end='', flush=True) results.append({'slug':slug,'name':name,'category':cat,'url':url,'description':'','question_count':qc,'questions':qs,'options':os_}) print(f' OK({qc})') existing=[] if os.path.exists('scales_data.json'): with open('scales_data.json') as f: existing=json.load(f) existing_slugs={s['slug'] for s in existing} for r in results: if r['slug'] not in existing_slugs: existing.append(r) with open('scales_data.json','w') as f: json.dump(existing, f, ensure_ascii=False, indent=2) total_q=sum(s['question_count'] for s in existing) print(f'Saved: {len(existing)} scales, {total_q} questions')