Open Live Writer 代码插入插件测试

  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):#定义取快递类型函数
  9     def getlist():#取快递类型列表
 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):#定义获取快递进度函数
 19     req = urllib.urlopen(url)
 20     html =  req.read()
 21     #type = sys.getfilesystemencoding()          #取文件系统编码类型
 22     #html = html.decode('utf-8').encode(type)    #utf-8解码  由于解码后和json里面解码冲突,故注释掉此段代码
 23     dict_info =json.loads(html)
 24     return dict_info['data']
 25 
 26 
 27 
 28 number= input(u"请输入快递单号:")
 29 
 30 type = gettype(number)#获取快递类型
 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']

测试一下,代码功能为查快递。

转载于:https://www.cnblogs.com/elijahxb/p/6477108.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值