Test the code insertion plug-in of Open Live Writer, livewriter
1 #-*-coding: UTF-8-*-2 import urllib 3 import json 4 import sys 5 import ssl 6 ssl. _ create_default_https_context = ssl. _ create_unverified_context 7 8 def gettype (number): # define the function 9 def getlist (): # retrieve the express type list 10 req = urllib. urlopen ('HTTP: // www.kuaidi100.com/autonumber/autoComNum? Text = % d' % number) 11 html = req. read () 12 dict_html = json. loads (html) 13 return dict_html ['auto'] 14 for I in getlist (): 15 type = I ['comcode'] 16 return type 17 18 def getprocess (url ): # define the function 19 req = urllib to get the delivery progress. urlopen (url) 20 html = req. read () 21 # type = sys. getfilesystemencoding () # obtain the file system encoding type 22 # html = html. decode ('utf-8 '). encode (type) # UTF-8 decoding the decoded Code 23 dict_info = json. load S (html) 24 return dict_info ['data'] 25 26 27 28 number = input (u "Please enter the express waybill number:") 29 30 type = gettype (number) # Get the courier type 31 32 33 Address = 'HTTP: // www.kuaidi100.com/query? Type = % s & postid = % d & id = 1 & valicode = & temp = 0.33020057185034335 '% (type, number) 34 for I in getprocess (Address ): 35 print I ['ftime'] + I ['context']
Test the code function.