python3中可用的UPS集成
ClassicUPS3的Python项目详细描述
ClassicUPS是一个Apache2许可的包装器,用于创建 运送标签和获取包裹的跟踪状态。不是这个图书馆吗 方法包括所有UPS功能,但它适用于 最常见的与运输相关的常见任务。在
特点
- 跟踪跟踪号的交货状态
- 创建GIF或EPL(热敏打印机)格式的预付运费标签
安装
安装简单:
$ pip install ClassicUPS
ClassicUPS依赖于libxml2和libxslt。在Ubuntu上,包是 libxml2-dev和libxslt-dev。在
快速启动
创建一个UPSConnection对象,该对象允许您访问常用的UPS方法:
^{pr2}$检查包裹的交货日期。在
tracking=ups.tracking_info('1Z12345E0291980793')printtracking.in_transitprinttracking.delivered
创建发货并将发货标签另存为GIF文件:
from_addr={'name':'Google','address1':'1600 Amphitheatre Parkway','city':'Mountain View','state':'CA','country':'US','postal_code':'94043','phone':'6502530000'}to_addr={'name':'President','address1':'1600 Pennsylvania Ave','city':'Washington','state':'DC','country':'US','postal_code':'20500','phone':'2024561111'}dimensions={# in inches'length':1,'width':4,'height':9}weight=10# in lbs# Create the shipment. Use file_format='EPL' for a thermal-printer-compatible EPLshipment=ups.create_shipment(from_addr,to_addr,dimensions,weight,file_format='GIF')# Print information about our shipmentprintshipment.costprintshipment.tracking_number# Save the shipping label to print, email, etcshipment.save_label(open('label.gif','wb'))
- 项目
标签: