您的位置:首页 > 编程语言 > Python开发

使用python获取webservice数据并输出到文件

2014-07-16 12:28 399 查看
上头要求设置TCP备案检查,给了个WEBSERVICE接口。查了2天,才确认还是python比较好用,我这水平也就写个脚本把数据导出,过滤检索还是用的shell。写此文备忘。WEBSERVICE接口脚本如下:
#! /usr/bin/python
#coding:utf-8
import codecs
import suds
def main(file_name, out_file):
url = 'http://121.14.4.210:8088/icpautobj/ws/getIcp?wsdl'
client = suds.client.Client(url)
fp=open(file_name)
ofp=codecs.open(out_file, 'w',"utf-8")
while 1:
line=fp.readline()
if not line or line == '\n':
break
domain=line.strip('\n')
ret = client.service.queryBatchIcpInfo(0,domain)
#print ret
ofp.write(ret+'\n')
fp.close()
ofp.close()

fn='domain.txt'
out_file='res.log'
main(fn, out_file)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  webservice python 输出