심 엽 프린터 WEB API HEX 모드 DEMO 호출

3218 단어 python
# -*- coding: utf-8 -*-#
#  https://www.cnblogs.com/mafeng/p/6292024.html   
import base64
import re
import urllib
import urllib2

url = "http://192.168.81.13/prt_test.htm"
data = {'hex_mode': 'on', 'Send': 'Print Test'}

content = u"""1000             :

ipconfig /flushdns 

             :

ipconfig /displaydns-----------------""".encode("gbk")

# Python             
content = re.sub(r"(?<=\w)(?=(?:\w\w)+$)", " ", base64.b16encode(content))

#     
data.update({"content": '1B 45 99 ' + content})

url = url + "?" + urllib.urlencode(data)
print(url)
response = urllib2.urlopen(url)
print(response.read())

좋은 웹페이지 즐겨찾기