Learn while you are practicing. Use Python to query for Express.
# coding:utf-8 ' Created on March 16, 2018 afternoon 12:12:52} @author: CHW ' ' Import requests as Req Import JSON import sys def
Getexpress (company, Code): "' Funcation:get Express infomation 2 args Company:the Express Company code
Code:the Express Bill code ' URL = ' http://www.kuaidi100.com/query?type={}&postid={} '. Format (company, code) Response = req.get (URL) if Response.status_code!= 200:print (' query failed.
{} '. Format (response.status_code)) return None def parse (text): Jsonobj = json.loads (text)
Print (' {} {} '). Format (' Current state: ', Jsonobj.get (' message ')) ' status = Jsonobj.get (' status ') # Get Status code (200 is normal) If status = = ': For x in Jsonobj.get (' data '): Print ('%s '% (x.get) (' time '), X.G ET (' context ')) Parse (response.text) def qureycomcode (mailno): Urlpara = ' http:// www.kuaidi100.com/autonumber/autocomnum?resultv2=1&text={} ' Paga = Req.get (Urlpara.format (mailno)) Jsonobj = Json.loads (Paga.text.decode (' UTF8 ')) if Paga.status_ Code!= 200:return None for item in Jsonobj.get (' Auto '): Return Item.get (' Comcode ') ret Urn None if __name__ = = ' __main__ ': Mailno = ' 813422761260 ' Comcode = Qureycomcode (mailno) if comcod E is None:print (' {} '. Format (' query failed ')) Sys.exit () getexpress (Comcode, Mailno)