get_equipment_info.py 510 B

1234567891011121314151617181920212223
  1. # -*- coding: utf-8 -*-
  2. import json
  3. import requests
  4. def query_equipment_info():
  5. url = 'http://api.sagacloud.cn/pythonserver/equipment_parameter_access/get_equipname_paramname/'
  6. response = requests.get(url, timeout=30)
  7. return response.json()
  8. def write_info(info):
  9. with open('equipment_info.json', 'wt') as f:
  10. json.dump(info.get('equipment_and_parameter'), f, ensure_ascii=False)
  11. print('Wrote to json file')
  12. if __name__ == '__main__':
  13. write_info(query_equipment_info())