57 lines
2.8 KiB
Python
57 lines
2.8 KiB
Python
import requests, time, urllib3
|
|
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
|
|
|
H = {
|
|
'Accept': 'application/json, text/plain, */*',
|
|
'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6ImEzck1VZ01Gdjl0UGNsTGE2eUYzekFrZnF1RSIsImtpZCI6ImEzck1VZ01Gdjl0UGNsTGE2eUYzekFrZnF1RSJ9.eyJpc3MiOiJodHRwczovL2F1dGgxLmhrczM2MC5jb20vY29yZSIsImF1ZCI6Imh0dHBzOi8vYXV0aDEuaGtzMzYwLmNvbS9jb3JlL3Jlc291cmNlcyIsImV4cCI6MTc4MDEyODg1MCwibmJmIjoxNzgwMTI1MjUwLCJjbGllbnRfaWQiOiJ6YS5jbGllbnQiLCJjbGllbnRfbG9jYXRpb24iOiJkYXRhY2VudGVyIiwic2NvcGUiOiJ3cml0ZSJ9.fiumtw9xCYWj-euP_LCQdrT9Wd4OsVopuHQpt3Qaae8En4lPA7aaqOfpXVF8gwxtoayfpjATtIaMomkUcnglYqZBCUTC50bc6IHYFgRrYl_7h4g9BCIHwGEswYbvFiQfAB5Q4gLFptzEJ1W2pjHnrNgmum5syQR3fsR5_25OayQ_KI6HWdtR3wReuInl0PQcDJs5jxdeId2ViDuYnl1x7TDFoIIwPov46H4KViUrBKFwr6iaTcNwrpl0thPBZjLJ8StTj50JwL1tRe71LbHkavD3MGsqs9_ulJaFZgyu2UYpl6cO0Let2zk9w-k2echh7P1ajQg7LfO2hEJ-c6RHXg',
|
|
'Content-Type': 'application/json;charset=utf-8',
|
|
'Origin': 'http://www.kuaixiuge.com',
|
|
'User-Agent': 'Mozilla/5.0',
|
|
}
|
|
U = 'http://saas.hks360.com:84/WXinfoservice/GetAllServices'
|
|
|
|
SVC = ['serviceid','servicename','servicetype','servicenumber','serviceprice','servicehj','timefee','isinquiry','isinterimpurchase']
|
|
XM = ['xmdm','xmname','xmprice','hour']
|
|
PT = ['pcode','pname','price','count','amount','unit']
|
|
|
|
OUT = ['serviceid','servicename','servicetype','servicenumber','serviceprice','servicehj','timefee','isinquiry','isinterimpurchase',
|
|
'xm_xmdm','xm_xmname','xm_xmprice','xm_hour',
|
|
'part_pcode','part_pname','part_price','part_count','part_amount','part_unit']
|
|
|
|
s = requests.Session()
|
|
|
|
for gch in ['245742605000037','245742605000039','245742108000042']:
|
|
print(f"\n=== {gch} ===")
|
|
s.options(U, params={'cid':'24574','gch':gch}, headers=H, verify=False, timeout=10)
|
|
time.sleep(0.15)
|
|
r = s.get(U, params={'cid':'24574','gch':gch}, headers=H, verify=False, timeout=15)
|
|
data = r.json()
|
|
rows = (data.get('rows') or []) if isinstance(data, dict) else []
|
|
print(f" rows={len(rows)}")
|
|
|
|
result = []
|
|
for row in rows:
|
|
si = {k: row.get(k) for k in SVC}
|
|
wxxm = row.get('wxxmList') or []
|
|
parts = row.get('wxinfopartsList') or []
|
|
has = False
|
|
if wxxm:
|
|
has = True
|
|
for x in wxxm:
|
|
m = dict(si)
|
|
for k in XM: m['xm_'+k] = x.get(k)
|
|
result.append(m)
|
|
if parts:
|
|
has = True
|
|
for p in parts:
|
|
m = dict(si)
|
|
for k in PT: m['part_'+k] = p.get(k)
|
|
result.append(m)
|
|
if not has:
|
|
result.append(si)
|
|
|
|
print(f" parsed={len(result)} rows")
|
|
for idx, d in enumerate(result[:3]):
|
|
vals = [str(d.get(k,''))[:30] for k in OUT]
|
|
print(f" [{idx}] {vals}")
|