Open Live Writer Code Insert plug-in test
#-*-coding:utf-8-*-import urllibimport jsonimport sysimport sslssl._create_default_https_context = Ssl._create_ Unverified_contextdef GetType (number): #定义取快递类型函数 def getlist (): #取快递类型列表 req = Urllib.urlopen (' Http://www.kuaidi1 00.com/autonumber/autocomnum?text=%d '%number) HTML = req.read () dict_html = json.loads (HTML) return dict_html[' Auto ' for I in GetList (): type = i[' Comcode '] return typedef getprocess (URL): #定义获取快递进度函数 req = Urllib.urlopen (URL) html = req.read () #type = sys.getfilesystemencoding () #取文件系统编码类型 #html = Html.deco De (' utf-8 '). Encode (type) #utf -8 decoding This Code dict_info =json.loads (HTML) return dict_info[' data ' due to decoding conflict with JSON number= input (U "Please enter the Courier Number:") type = GetType (number) #获取快递类型Address = ' Http://www.kuaidi100.com/query?type=%s&postid =%d&id=1&valicode=&temp=0.33020057185034335 '% (type,number) for I in GetProcess (Address): Print i[' Ftime ' ] + i[' context ']
Test, the code function for check Express.