-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_suds.py
38 lines (38 loc) · 1.09 KB
/
test_suds.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#encoding=utf-8
from suds.client import Client
url='http://192.168.4.228:8080/ContentService/CrawledIndex?wsdl'
client = Client(url)
# print client
pageInfo=client.factory.create('pageInfo')
pageInfo.pageNum = 1
pageInfo.pageSize = 10
searchInfo=client.factory.create('searchInfo')
searchInfo.serviceType = "baiduBaikeCrawler"
searchInfo.keyValueInfo = client.factory.create('keyValueInfo')
searchInfo.keyValueInfo.key = "keyword"
searchInfo.keyValueInfo.value = u"搜索"
n=client.service.getEntityList(pageInfo,searchInfo)
file("suds.txt","w").write(str(n))
children={}
def getv(o):
if hasattr(x,"value"):
return x.value
return None
for x in n.components[0].children:
print x
if hasattr(x,"properties"):
for y in x.properties:
children.setdefault(x.name,[]).append(y.key)
res=dict([(x.key,getv(x)) for x in n.components[0].properties])
print children
category=children["Category"]
expand=children["ExpandRead"]
refer=children["ReferData"]
# print v
# print v
for k,v in category.iteritems():
print "[%s]"%k
for k,v in expand.iteritems():
print "[%s]"%k
for k,v in refer.iteritems():
print "[%s]"%k