免费的快递查询接口,不需要key

免费的快递查询接口

1.第一个接口只需要快递单号就可以查询。
https://sp0.baidu.com/9_Q4sjW91Qh3otqbppnN2DJv/pae/channel/data/asyncqury?cb=jQuery110204759692032715892_1499865778178&appid=4001&com=&nu=运单号。
2.第二个接口,需要两个参数,快递公司标识码
(参考快递100接口:https://cdn.kuaidi100.com/download/chaxun(20140729).doc)和运单号。
http://www.kuaidi100.com/query?type=快递公司标识码&postid=运单号

以下案例我是用python来写的,初学者python,请各位大佬指教。

import urllib.request,json

kd_dict = {1:'shentong',2:'youzhengguonei',3:'yuantong',4:'shunfeng',5:'yunda',6:'zhongtong',7:"tiantian",8:"debangwuliu",9:'huitongkuaidi'}

def Check():
    while True:
        print("仅支持以下快递公司查询:")
        print("1.申通快递")
        print("2.EMS邮政    ")
        print("3.圆通快递")
        print("4.顺风快递")
        print("5.韵达快递")
        print("6.中通快递")
        print("7.天天快递")
        print("8.德邦物流")
        print("9.汇通快递")
        print("0.退出\n")
        choose = int(input("请选择您的快递公司:"))
        while choose not in range(0,9):
            choose = int(input("抱歉暂不支持此公司请重新选择:"))
        if choose == 0:
            print("感谢使用!\n")
            break
        kd_num = input("请输入快递单号:")
        url = "http://www.kuaidi100.com/query?type=%s&postid=%s" % (kd_dict[choose], kd_num)
        response = urllib.request.urlopen(url)
        html = response.read().decode('utf-8')
        target = json.loads(html)
        status = target['status']
        if status == '200':
            data = target['data']
            data_len = len(data)
            for i in range(data_len):
                print("\n时间: " + data[i]['time'])
                print("状态: " + data[i]['context'] + "")
            print("\n感谢使用!\n")
            break
        else:
            print("输入有误请重新输入!\n")

if __name__ == '__main__':
    while True:
        Check()
        out = input("按任意数字退出(其他键继续).........")
        if out >= '0' and out <= '9':
            break
        else:
            print("\n")
            continue

            # 3926978083099 韵达快递

以下为运行结果:
在这里插入图片描述

  • 1
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 10
    评论
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值