Skip to content

Instantly share code, notes, and snippets.

@shell909090
Created January 1, 2022 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shell909090/f29c3940f3400c4a45bbd74076a6a800 to your computer and use it in GitHub Desktop.
Save shell909090/f29c3940f3400c4a45bbd74076a6a800 to your computer and use it in GitHub Desktop.
import json
import time
import hashlib
import requests
def sha256sum(s):
h = hashlib.sha256()
h.update(s.encode('utf-8'))
return h.hexdigest().upper()
def yqfxdjcx():
url = 'http://103.66.32.242:8005/zwfwMovePortal/interface/interfaceJson'
timestamp = str(int(time.time()))
headers = {
'Content-Type': 'application/json; charset=utf-8',
'x-wif-nonce': 'QkjjtiLM2dCratiA',
'x-wif-paasid': 'smt-application',
'x-wif-signature': sha256sum(timestamp + 'fTN2pfuisxTavbTuYVSsNJHetwq5bJvC' + 'QkjjtiLM2dCratiA' + timestamp),
'x-wif-timestamp': timestamp,
}
body = {
'appId': 'NcApplication',
'paasHeader': 'zdww',
'timestampHeader': timestamp,
'nonceHeader': '123456789abcdefg',
'signatureHeader': sha256sum(timestamp + '23y0ufFl5YxIyGrI8hWRUZmKkvtSjLQA' + '123456789abcdefg' + timestamp),
'key': '3C502C97ABDA40D0A60FBEE50FAAD1DA',
}
resp = requests.post(url, headers=headers, data=json.dumps(body))
if resp.status_code != 200:
raise Exception(f'http code error: {resp.status_code}')
data = resp.json()
if data['code'] != 0:
raise Exception(f'json error: {data["msg"]}')
return data['data']
def list2set(l):
return {f'{o["province"]} {o["city"]}' for o in l}
def main():
import pprint
data = yqfxdjcx()
highset = list2set(data['highlist'])
middleset = list2set(data['middlelist'])
print('high:')
for n in highset:
print(n)
print('middle:')
for n in middleset:
if n not in highset:
print(n)
if __name__ == '__main__':
main()
@luxiaba
Copy link

luxiaba commented Jan 1, 2022

It seems that pprint no need to be imported or use pprint.pprint instead.

@shell909090
Copy link
Author

Yeah you're right. I used to use pprint dumping out everything in data, which will be much easier. After that I removed the code but forgot the import.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment