gpt4 book ai didi

python - 如何从 Python 中的 Soap 响应中提取特定信息 (pysimplesoap)

转载 作者:太空宇宙 更新时间:2023-11-04 03:48:44 24 4
gpt4 key购买 nike

我开始使用 pysimplesoap 在 python 中编写代码。首先针对 Internet 上可用的服务进行测试。我一直在尝试解析 Soap 查询的结果。我编码:

#!/usr/bin/python
from pysimplesoap.client import SoapClient
import pysimplesoap
import logging
logging.basicConfig()

client=SoapClient(wsdl="http://ws.cdyne.com/emailverify/Emailvernotestemail.asmx?wsdl",trace=True)
response = client.VerifyEmail(email="a-valid-gmail-address@gmail.com",LicenseKey="?")
print response

我得到以下信息,这意味着 Soap 请求是肯定的:

{'VerifyEmailResult': {'GoodEmail': True, 'LastMailServer': u'gmail-smtp-in.l.google.com', 'ResponseText': u'Mail Server will accept email', 'ResponseCode': 3}}

我现在想从“response”中提取等于 True 的 GoodEmail 值,并将其存储在名为“result”的变量中。我尝试了各种各样的事情,但没有成功。我必须承认我是 Python 的新手,非常感谢知识渊博的人的帮助!

最佳答案

您得到的响应是一个 Python dict。您可以像这样访问 GoodEmail 值:

result = response['VerifyEmailResult']['GoodEmail']

您可以在此处阅读有关 Python 数据类型的更多信息:http://docs.python.org/2/library/stdtypes.html

关于python - 如何从 Python 中的 Soap 响应中提取特定信息 (pysimplesoap),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22383857/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com