python 调用 telnet

import telnetlib

import sys
reload(sys)
sys.setdefaultencoding('utf-8')

conn = telnetlib.Telnet()

conn.open('localhost', 20881)

cmd = 'com.xxxx.xxxx.service.XxxxService.xxxx({"currency":"CCN6M","endTime":"2021-01-29 23:47:01","startTime":"2021-01-29 00:35:01","type":"ONE_DAY","class":"com.xxxx.xxxx.service.request.xxxx"})'

conn.write('invoke {0}\n'.format(cmd).encode())

data = conn.read_until('dubbo>'.encode()).decode().split('\r\n')[0]

print(data)

 

posted on 2021-02-04 09:43  13rj1115  阅读(275)  评论(0编辑  收藏  举报

导航