You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.3 KiB
39 lines
1.3 KiB
|
1 week ago
|
from suds.client import Client
|
||
|
|
import xml_to_dict
|
||
|
|
from lib.gzip_base64 import ungzip_base64_dh2cmc
|
||
|
|
|
||
|
|
|
||
|
|
class GetCinemas:
|
||
|
|
def __init__(self, url, cid):
|
||
|
|
self.ws_client = Client(url)
|
||
|
|
self.user_name = 'TUOWEI' # 固定写死的参数
|
||
|
|
self.password = '668CBE9A6BCF4ABB' # 固定写死的参数
|
||
|
|
self.cinema_id = cid
|
||
|
|
self.xml_parse = xml_to_dict.XMLtoDict()
|
||
|
|
|
||
|
|
# getCinemas(xs:string UserName, xs:string Password, )
|
||
|
|
def get_cinemas(self):
|
||
|
|
print('-' * 100 + '\n' + '请求getCinemas接口')
|
||
|
|
data = {
|
||
|
|
'UserName': self.user_name, # 授权用户名
|
||
|
|
'Password': self.password, # 授权密码
|
||
|
|
}
|
||
|
|
result_xml = self.ws_client.service.getCinemas(**data)
|
||
|
|
if 'xml' in result_xml:
|
||
|
|
result_dict = self.xml_parse.parse(result_xml)
|
||
|
|
else:
|
||
|
|
print(f"-- gzip加密结果 --\n{result_xml}")
|
||
|
|
result_xml = ungzip_base64_dh2cmc(result_xml)
|
||
|
|
result_dict = self.xml_parse.parse(result_xml)
|
||
|
|
print(f"-- xml结果 --\n{result_xml}")
|
||
|
|
print("-- Dict结果 --")
|
||
|
|
print(result_dict)
|
||
|
|
return result_dict
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
soap_url = 'http://192.168.55.99/webservice/?wsdl'
|
||
|
|
cinema_id = '304'
|
||
|
|
api_get_cinemas = GetCinemas(soap_url, cinema_id)
|
||
|
|
api_get_cinemas.get_cinemas()
|