1.https://www.kuaidi100.com/ 快递100的网址
http://www.kuaidi100.com/query
1.支持顺丰,圆通,申通,中通,韵达,宅急送,EMS,天天,速尔,优速,全峰,德邦 快递单识别
2.条码识别率高,高清摄像头图像清晰
3.实时拍摄、实时显示
4.兼容各种USB摄像头和工业相机(已测支持所有SKT系列工业相机和铖镒顺摄像头模组)
5.识别速度快,免费开源产品!
6.支持电脑内置摄像头识别快递单号
7.自动识别条码和二维条码,识别率达到99.9%以上,能识别所有快递公司的快递单。
8.对未识别的快递单,可以手动修改,操作简单。
9.自动以条码单号作为单据图像的文件名。
10.单据图像采用高压缩技术,每张图像少于100KB。
11.网络唯一一款免费的快递单识别软件
12.支持设置各种分辨率识别!越清晰识别越快!
代码
import requests
import json
import re
import pprint
class EXPRESS100:
postID = ''
def __init__(self, data):
self.postID = data
def getPostMsg(self):
url_json = self.geturl()
url_json_num = len(url_json)
""" 检测出正确的快递公司 """
for i in range(url_json_num):
url = 'http://www.kuaidi100.com/query'
data = {
'type': url_json[i]['comCode'],
'postid': self.postID,
'temp': '0.916395518853228'
}
res = requests.get(url, params=data).text
pMsg = re.findall(r'message\":\"(.*?)\"', res)[0]
if pMsg == 'ok':
right_data = re.findall(r'data\":(.*?\])', res)[0]
return right_data # 得到快递信息,可以自行解析list
def geturl(self):
url = 'http://www.kuaidi100.com/autonumber/autoComNum?resultv2=1&text=' + self.postID
header = {
'Referer': 'http://www.kuaidi100.com/',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36',
'X-Requested-With': 'XMLHttpRequest'
}
datas = {
'resultv2': '1',
'text': self.postID
}
res = requests.post(url, headers=header, data=datas).text
data = re.findall(r'auto":(.*?\])', res)[0]
data_json = json.loads(data)
return data_json
if __name__ == '__main__':
p = EXPRESS100('75312271522183') # 输入快递单号
res = p.getPostMsg()
pprint.pprint(res)
输出
('[{"time":"2019-11-15 05:57:33","ftime":"2019-11-15 '
'05:57:33","context":"【嘉兴市】 快件已到达 【嘉兴秀洲】(0573-83964725),业务员 '
'塘汇开发区-毕在江(15868398065) 正在第1次派件, '
'请保持电话畅通,并耐心等待(95720为中通快递员外呼专属号码,请放心接听)","location":""},{"time":"2019-11-15 '
'03:59:47","ftime":"2019-11-15 03:59:47","context":"【嘉兴市】 快件离开 【嘉兴中转部】 已发往 '
'【嘉兴秀洲】","location":""},{"time":"2019-11-15 03:50:56","ftime":"2019-11-15 '
'03:50:56","context":"【嘉兴市】 快件已经到达 '
'【嘉兴中转部】","location":""},{"time":"2019-11-15 00:17:23","ftime":"2019-11-15 '
'00:17:23","context":"【苏州市】 快件离开 【苏州中转部】 已发往 '
'【嘉兴中转部】","location":""},{"time":"2019-11-15 00:10:13","ftime":"2019-11-15 '
'00:10:13","context":"【苏州市】 快件已经到达 '
'【苏州中转部】","location":""},{"time":"2019-11-13 20:08:34","ftime":"2019-11-13 '
'20:08:34","context":"【苏州市】 快件离开 【苏州园区九部】 已发往 '
'【苏州中转部】","location":""},{"time":"2019-11-13 20:02:09","ftime":"2019-11-13 '
'20:02:09","context":"【苏州市】 【苏州园区九部】(18014003566、0512-87807283) 的 '
'小郑(15506291427) 已揽收","location":""}]')
[Finished in 1.2s]
('[{"time":"2019-11-15 05:57:33","ftime":"2019-11-15 '
'05:57:33","context":"【嘉兴市】 快件已到达 【嘉兴秀洲】(0573-83964725),业务员 '
'塘汇开发区-毕在江(15868398065) 正在第1次派件, '
'请保持电话畅通,并耐心等待(95720为中通快递员外呼专属号码,请放心接听)","location":""},{"time":"2019-11-15 '
'03:59:47","ftime":"2019-11-15 03:59:47","context":"【嘉兴市】 快件离开 【嘉兴中转部】 已发往 '
'【嘉兴秀洲】","location":""},{"time":"2019-11-15 03:50:56","ftime":"2019-11-15 '
'03:50:56","context":"【嘉兴市】 快件已经到达 '
'【嘉兴中转部】","location":""},{"time":"2019-11-15 00:17:23","ftime":"2019-11-15 '
'00:17:23","context":"【苏州市】 快件离开 【苏州中转部】 已发往 '
'【嘉兴中转部】","location":""},{"time":"2019-11-15 00:10:13","ftime":"2019-11-15 '
'00:10:13","context":"【苏州市】 快件已经到达 '
'【苏州中转部】","location":""},{"time":"2019-11-13 20:08:34","ftime":"2019-11-13 '
'20:08:34","context":"【苏州市】 快件离开 【苏州园区九部】 已发往 '
'【苏州中转部】","location":""},{"time":"2019-11-13 20:02:09","ftime":"2019-11-13 '
'20:02:09","context":"【苏州市】 【苏州园区九部】(18014003566、0512-87807283) 的 '
'小郑(15506291427) 已揽收","location":""}]')
[Finished in 1.2s]
参考文档