Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method of querying express delivery by Python?

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "what is the method of Python query express delivery". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

First of all, consider the data source. This can use the data of express delivery 100, open the official website of express delivery 100, you can enter the order number to query the express delivery information.

Of course, clicking the query button will send a lot of requests to the server for express information. We need to analyze which request links are useful. Grab packet analysis can use fiddler4, I will not write this process here.

After testing, the request link is http://www.kuaidi100.com/query?type=xxx&postid=xxx. You need to fill in two parameters, type and postid, which are the express company code and the express order number respectively. Request this link to get the json data. The approximate structure is as follows:

{"message": "ok", "nu": "order number", "com": "Express company code", "data": [{"time": "2015-12-27 13:24:34", "context": "Express Info 1", "ftime": "2015-12-27 13:24:34"} {"time": "2015-12-27 13:24:34", "context": "Express message 2", "ftime": "2015-12-27 13:24:34"}]}

The json data structure is clear at a glance, so we can do it. The source code is as follows:

#-*-coding: UTF-8-*-

# Special statement: this source code is for reference only. Do not use it for commercial purposes without permission

# By Haddy Yang, 2016-03-02

Import urllib

Import json

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=%s&postid=%s'% (company,code)

Page=urllib.urlopen (url) # Open the link and request express data

Return page.read () .decode ('utf8')

Def showResult (jsonStr):

'' Show the result'''

JsonObj = json.loads (jsonStr)

Print u 'current status:', jsonObj.get ('message'),'\ n'

Status=jsonObj.get ('status') # get the status code (200 is normal)

If status=='200':

For x in jsonObj.get ('data'):

Print's% s'% (x.get ('time'), x.get (' context'))

# you can traverse the full key value with the following code

# for key,value in x.items ():

# print key,value

If _ _ name__ = ='_ _ main__':

# Test, Shun Feng Code: shunfeng

JsonStr = getExpress ('shunfeng','102290224058')

ShowResult (jsonStr)

Raw_input ()

The name of the express company begins with code A.

Rush to the beginning of Jixianda micro-special mission weitepai Australia Post auspost Jinyue Express jinyuekuaidiX

AAEaae Jet Express jietekuaidi Xinbang Logistics xinbangwuliu Anda anxindakuaixi Jindai Logistics jindawuliu Xinfeng Logistics xinfengwuliuB start Kerry Chase jialidatong XingchengjianxingchengjianBai Huitong huitongkuaidiK start

Xin Feihong xinhongyukuaidi Baifu Oriental baifudongfang Express kuaijiesudi Xia ccesBHTbht Kang Li Logistics kangliwuliu New Egg Olympian Logistics neweggozzo parcels / Surface Mail / registered youzhengguonei across Logistics kuayue Hongkong Post hkpost State delivery Logistics bangsongwuliuL beginning

Y beginning

Start with C

Unicom lianhaowuliu Yuantong Express yuantong Xiyais cces Longbang Logistics longbanwuliu Yunda Express yunda Chuan Xi Logistics chuanxiwuliu Blue Dart Express lanbiaokuaidi Express yuntongkuaidiD beginning

LedEx lejiedi Postal Parcel youzhengguonei Daejeon Logistics datianwuliu FedEx lianbangkuaidi Postal Parcel youzhengguoji Debon Logistics debangwuliu FedEx lianbangkuaidien far Cheng Logistics yuanchengwuliuDPEXdpex immediate delivery lijisong Yafeng Express yafengsudiDHL- Chinese parts dhl Longlang Express longlangkuaidi one Bond Express yibangwuliuDHL- International parts dhlenM beginning

Excellent Speed Logistics youshuwuliuDHL- German parts dhlde door to door menduimen Source Weifeng Express YuanweifengD Express dsukuaidi American Express meiguokuaidi Yuan Zhicheng yuanzhijiecheng delivery Sifang disifang Bright Logistics mingliangwuliu Yuefeng Logistics yuefengwuliuE

O beginning

Source Anda yuanandaEMSemsOCSocs original flight yuanfeihangwuliuEMS- international parts emsenonTracontrac unified Feihong yitongfeihongE post treasure emsQ beginning

Z begins with F

Morning Express quanchenkuaidi Zhongxinda Express zhongxindaFedex- International parts quanjitong Sesame door zhimakaimenFedex- China parts fedexcn all-day pass quanritongkuaidi Silver Jet Express yinjiesudiFedex- fedexus all-in-one Express quanyikuaidi delivery zhaijisong Feikangda Logistics feikangda Quanfeng Express quanfengkuaidi Zhengzhou Jianhua zhengzhoujianhua Flying Express seven-day chain sevendays China Oriental coe VANCL Rufengda rufengdaR beginning

Zhongtong Express zhongtong is popular all over the world fengxingtianxia such as Fengda Express rufengda China Railway Logistics zhongtiewuliu Flying Leopard Express feibaokuaidiS

The beginning of China Railway Express ztkyG

Shandong Haihong haihongwangsong China Post Logistics zhongyouwuliu Port can reach ganzhongnengda Shentong Express shentong medium Speed Express zhongsukuaidi Guotong Express guotongkuaidi Shunfeng Express shunfeng Zhongtian Wanyun zhongtianwanyun Guangdong Post guangdongyouzhengwuliu Shunfeng Express-International shunfengen

Registered letter youzhengguonei three-state express santaisudi

Domestic mail youzhengguonei Sueer Logistics suer

International mail youzhengguoji Shenghui Logistics shenghuiwuliu

GLSgls Shengfeng Logistics shengfengwuliu

Co-speed to gongsuda on the big logistics shangda

Start with H

Saaodi saiaodi

Huitong express huitongkuaidi Shanxi red horse armour sxhongmajia

Huiqiang Express huiqiangkuaidi Shengan Logistics shenganwuliu

Huayu Logistics tiandihuayu Suijia Logistics suijiawuliu

The beginning of Henglu Logistics hengluwuliuT

Huaxia Dragon huaxialongwuliu Heaven and Earth Huayu tiandihuayu

HNA tiantian Daily Express tiantian

Overseas Global haiwaihuanqiuTNTtnt

Hebei Jianhua hebeijianhuaTNT- International tnten

Haimeng Express haimengsudi and World tonghetianxia

The beginning of huaqikuaiyunU of China Enterprise Express

J beginning

UPSups

Canada Post canpostUPS- International upsen

Canada Post canpostfrUSPSusps

Jiaji Logistics jiajiwuliu High Speed Logistics youshuwuliu

The beginning of Jiayi Logistics jiayiwuliuW

Canada Jiayunmeiwuliu million logistics wanjiawuliu

Beijing-Guangzhou Express inguangsudikuaijian Vientiane Logistics wanxiangwuliu

This is the end of the content of "what is the method of Python inquiry express delivery". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report