Armatis解析韩国包裹递送服务公司的网站或Web API响应,以跟踪包裹。

armatis的Python项目详细描述


https://img.shields.io/badge/License-BSD%202--Clause-blue.svghttps://badge.fury.io/py/armatis.svghttps://travis-ci.org/iBluemind/armatis.svg?branch=masterhttps://readthedocs.org/projects/armatis/badge/

armatis解析韩国人的网站或web api响应 包裹递送服务公司负责包裹追踪。

安装

使用以下命令安装armatis:

$ pip install armatis

用法

犰狳使用简单。只需要输入送货公司代码 以及发票号码。

要找到包裹,只需使用方法find()

fromarmatisimportArmatistracker=Armatis('cj',123456789123)tracker.find()

您可以使用方法supported_companies()查找支持的 送货公司名称和公司代码。

tracker.supported_companies()

方法find()的返回数据如下:

{"company":{"contact":"1588-1255","name":"CJ대한통운"},"parcel":{"receiver":"(주*","sender":"한만*","note":"일반","address":"경기도 성남시 분당구******"},"tracks":[{"time":"2016-10-13 18:07:13","status":"간선상차","location":"파주Sub","phone1":"파주Sub(031-960-6566)","phone2":null},{"time":"2016-10-13 21:22:09","status":"집화처리","location":"경기파주","phone1":"경기파주(070-7779-1003)","phone2":null},{"time":"2016-10-14 02:06:39","status":"간선하차","location":"옥천HUB","phone1":null,"phone2":null},{"time":"2016-10-14 02:17:16","status":"간선하차","location":"옥천HUB","phone1":null,"phone2":null},{"time":"2016-10-14 02:25:10","status":"행낭포장","location":"옥천HUB","phone1":null,"phone2":null},{"time":"2016-10-14 04:06:49","status":"간선상차","location":"옥천HUB","phone1":null,"phone2":null},{"time":"2016-10-14 11:10:05","status":"간선하차","location":"분당A","phone1":"분당A(031-725-9222)","phone2":null},{"time":"2016-10-14 11:12:07","status":"배달출발","location":"분당대리점a(C15F)","phone1":"분당대리점a(C15F)(031-769-0516)","phone2":"01012345678"},{"time":"2016-10-14 16:44:35","status":"배달완료","location":"분당대리점a(C15F)","phone1":"분당대리점a(C15F)(031-769-0516)","phone2":"01012345678"}]}

支持的送货公司

目前支持以下送货公司。

CompanyTest existedLast Updated
CJ대한통운, CVSNet편의점택배o2016-12-10
로젠택배o2016-12-10
현대택배o2016-12-10
한진택배o2016-12-10
KG로지스o2016-12-10
GTX로지스o2017-01-02
우체국택배o2017-01-06
합동택배o2017-01-06
EMSo2017-01-02
KGB택배o2017-01-02

如何添加新公司

您可以轻松地创建新的交付公司解析器。

首先,创建一个继承Parser的类,并实现该方法 parse()

fromarmatis.modelsimportParcel,Trackfromarmatis.parserimportParser,ParserRequestclassNewCompanyParser(Parser):def__init__(self,invoice_number,config):super(NewCompanyParser,self).__init__(invoice_number,config)# Describe the information about the website or web API provided by the delivery companyparser_request=ParserRequest(url='http://thecompany.co.kr/tracking?invno=%s'%self.invoice_number)self.add_request(parser_request)# Actually occurred parsing the website or web API provided abovedefparse(self,parser):tables=parser.find_all('tbody')parcel=Parcel()parcel.sender=...# Sender's nameparcel.receiver=...# Receiver's nameparcel.address=...# Receive addressparcel.note=...# Describe about the parcelself.parcel=parcel# Store the information about the parcel!trs=tables[1].find_all('tr')fortrintrs:track=Track()track.status=...# Status of the delivery historytrack.time=...# Time of the delivery historytrack.location=...# Location the parcel where it istrack.phone1=...# Contact of the locationtrack.phone2=...# Contact of the locationself.add_track(track)# Add the tracking information!
然后,创建一个描述公司的Company实例。
最后,用Parser类注册这个Company对象 你在上面做的。
fromarmatisimportArmatis,Companytracker=Armatis()# Make a Company instance that describe the companythe_new_company=Company('새로운회사','nc','1234-5678',[10,12])# Register the Company object with the Parser class you madetracker.parser_manager.register_parser(the_new_company,NewCompanyParser)

文档

有关ARMATIS的完整文档,请访问 ReadtheDocs

贡献

欢迎投稿!如果你想在军备方面做贡献, 请遵循以下步骤:

  1. 分叉此存储库
  2. 进行更改
  3. 使用pip install -r requirements.txt
  4. 安装需求
  5. 运行make ready
  6. 后提交拉取请求

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何使Sonar maven插件示例工作   java Log4j2根记录器appender不工作   awt是否有其他方法可以获得整个屏幕的截图?(爪哇)   java我不知道为什么我在测试中得到了超出界限的索引。查拉特(1)   java在JavaFXCSS中fxtextfill和fxtextinnercolor之间有什么区别?   java Edittext输入小于100的百分比值,小数点后只能输入两位数字   java Oracle PreparedStatement NullPointerException适用于某些开发人员,但并非所有开发人员   amazon web services如何在java中获取S3中文件的最新时间   正在分析Java IndexOf找不到正确的数据   int[]到List<int>的java类型映射   apache commons Exec程序不包含在Java路径中   java使用Uri构建URL。建设者   Perl调用Java   java ScrollView阻止某些操作   使用eclipse将文件推送到安卓设备时遇到的java问题   java声明未与列映射的hibernate POJO布尔属性   java“赋值的左侧必须是一个变量”,因为有额外的括号   带有JSON约束的java Android POST请求