import random
import time
from suds.client import Client
from suds.xsd.doctor import Import,ImportDoctor
from suds.client import Client
import json
# 1 天气预报Web服务,数据来源于中国气象局
# api_url = 'http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl' # ok
# imp = Import('http://www.w3.org/2001/XMLSchema',location='http://www.w3.org/2001/XMLSchema.xsd')
# imp.filter.add('http://WebXml.com.cn/')
# doctor = ImportDoctor(imp)
# client = Client(api_url,doctor=doctor)
# print('查询服务端方法:\n' + str(client))
# res = client.service.getWeatherbyCityName(u'北京')
# print(res)
# 地址来源搜索 WEB 服务(是目前最完整的IP地址数据)
# api_url = 'http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx?wsdl'
# client = Client(api_url)
# print('查询服务端方法:\n' + str(client))
# res = client.service.getCountryCityByIp('114.114.114.114')
# res = client.service.getCountryCityByIp('192.168.1.1')
# print(res)
# 随机英文、数字和中文简体字 WEB 服务
# api_url = 'http://www.webxml.com.cn/WebServices/RandomFontsWebService.asmx?wsdl'
# client = Client(api_url)
# print('查询服务端方法:\n' + str(client))
# res = client.service.getCharFonts('97')
# print(res)
# 中国邮政编码 <-> 地址信息双向查询/搜索 WEB 服务
# api_url = 'http://www.webxml.com.cn/WebServices/ChinaZipSearchWebService.asmx?wsdl' # ok
# imp = Import('http://www.w3.org/2001/XMLSchema',location='http://www.w3.org/2001/XMLSchema.xsd')
# imp.filter.add('http://WebXml.com.cn/')
# doctor = ImportDoctor(imp)
# client = Client(api_url,doctor=doctor)
# print('查询服务端方法:\n' + str(client))
# # res = client.service.getSupportCity(u'新疆')
# res = client.service.getSupportProvince()
# print(res)
# 验证码图片 WEB 服务 支持中文、字母、数字 图像和多媒体
# api_url = 'http://www.webxml.com.cn/WebServices/ValidateCodeWebService.asmx?wsdl'
# client = Client(api_url)
# print('查询服务端方法:\n' + str(client))
# res = client.service.cnValidateByte('不错不错')
# print(res)
# Email 电子邮件地址验证 WEB 服务
# api_url = 'http://www.webxml.com.cn/WebServices/ValidateEmailWebService.asmx?wsdl' # ok
# client = Client(api_url)
# print('查询服务端方法:\n' + str(client))
# res = client.service.ValidateEmailAddress('test@qq.com')
# print(res)
# 中文简体字 <->繁体字转换 WEB 服务
# api_url = 'http://www.webxml.com.cn/WebServices/TraditionalSimplifiedWebService.asmx?wsdl' # ok
# client = Client(api_url)
# 中文 <-> 英文双向翻译 WEB 服务
# api_url = 'http://www.webxml.com.cn/WebServices/TranslatorWebService.asmx?wsdl' # ok
# client = Client(api_url)
# print('查询服务端方法:\n' + str(client))
# # res = client.service.getEnCnTwoWayTranslator('test')
# # res = client.service.getEnCnTwoWayTranslator('智能')
# res = client.service.getEnCnTwoWayTranslator('智能test')
# print(res)
# 火车时刻表 WEB 服务 (第六次提速最新列车时刻表)
# api_url = 'http://www.webxml.com.cn/WebServices/TrainTimeWebService.asmx?wsdl' # ok
# imp = Import('http://www.w3.org/2001/XMLSchema',location='http://www.w3.org/2001/XMLSchema.xsd')
# imp.filter.add('http://WebXml.com.cn/')
# doctor = ImportDoctor(imp)
# client = Client(api_url,doctor=doctor)
# print('查询服务端方法:\n' + str(client))
# # res = client.service.getStationNameDataSet()
# res = client.service.getStationName()
# print(res)
# 国内飞机航班时刻表 WEB 服务
# api_url = 'http://www.webxml.com.cn/webservices/DomesticAirline.asmx?wsdl' # ok
# imp = Import('http://www.w3.org/2001/XMLSchema',location='http://www.w3.org/2001/XMLSchema.xsd')
# imp.filter.add('http://WebXml.com.cn/')
# doctor = ImportDoctor(imp)
# client = Client(api_url,doctor=doctor)
# # client = Client(api_url)
# print('查询服务端方法:\n' + str(client))
# res = client.service.getDomesticAirlinesTime('北京','烟台','2019-04-25')
# print(res)