gpt4 book ai didi

python - 如何处理 API 响应

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

我能够连接到 Mind Body api 并运行一个简单的命令来获取所有客户端数据

from Helper.ClientService import ClientServiceCalls

calls = ClientServiceCalls()
clients = calls.GetAllClients()
print(clients)

服务器将响应这些信息:

(GetClientsResult){
Status = "Success"
ErrorCode = 200
XMLDetail = "Full"
ResultCount = 4503
CurrentPageIndex = 0
TotalPageCount = 181
Clients =
(ArrayOfClient){
Client[] =
(Client){
MobileProvider = None
AppointmentGenderPreference = "None"
Gender = "Female"
IsCompany = False
LiabilityRelease = False
PromotionalEmailOptIn = True
CreationDate = 2017-02-23 00:00:00
Liability =
(Liability){
IsReleased = False
AgreementDate = None
ReleasedBy = None
}
UniqueID = 100015484
ID = "100015484"
FirstName = "Sdfoij"
LastName = "[asodfj"
EmailOptIn = True
State = "CA"
Country = "US"
BirthDate = None
FirstAppointmentDate = 2017-03-03 00:00:00
HomeLocation =
(Location){
SiteID = -99
BusinessDescription = ""The MINDBODY Health Club Demo is awesome." - Anonymous (but probably someone cool and smart)"
AdditionalImageURLs = ""
FacilitySquareFeet = None
TreatmentRooms = None
HasClasses = True
PhoneExtension = None
ID = 1
Name = "Clubville"
}
PhotoURL = "https://clients.mindbodyonline.com/studios/DemoAPISandboxRestore/clients/100015484_large.jpg?v=98"
IsProspect = False
Status = "Active"
ContactMethod = 1
}.... **and continue printing other client informations**

}
}

现在的问题是我想从中提取这些信息,

Client Email, Client Name, Client Phone Number, Client Status (active or inactive), Client Birthday, Client Address, Most Recent Visit Date, Most Recent Visit Description, Start Date, Custom Field(s)

但我不知道我可以使用什么库来解析这个输出,我正在考虑 Beautiful Soup 但我不太确定,

我真的是使用 api 的新手,所以如果有人能告诉我如何做到这一点,那就太好了。

最佳答案

好的,我在 googs 中搜索了 mindbody WSDL 并找到了以下链接:https://api.mindbodyonline.com/0_5/SiteService.asmx?wsdl .通过查看 API 示例中的代码,他们似乎确实在使用 SOAP。我的建议是您尝试以下操作:

from suds.client import Client
from Helper.ClientService import ClientServiceMethods
calls = ClientServiceMethods()
clients = calls.GetAllClients()
client_dict = Client.dict(clients)

或者看看这个link采取回应并将其转化为口述。

关于python - 如何处理 API 响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43101703/

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