Help us understand the problem. What is going on with this article?

Pythonでヤマト運輸の荷物追跡

More than 3 years have passed since last update.

Pythonを用いてヤマト運輸の荷物を追跡します。
使用しているmoduleは
requests : http://docs.python-requests.org/en/latest/
のみです。

このコードは下記APIを利用しています。提供者さんありがとうございます。
http://nanoappli.com/blog/archives/603

因みにこのコードはお問い合わせ番号を整数型であることを前提としています。string型などがでるとType-errorか何か出ると思います()

ヤマト運輸荷物追跡.py
#coding: utf-8

import requests

def GET_status(number):
    URL_JSON = 'http://nanoappli.com/tracking/api/%d.json' % number
    r = requests.get(URL_JSON)
    j = r.json()
    status = j['status']
    itemType = j['itemType']
    slipNo = j['slipNo']
    statusList = j['statusList']
    for status_ in statusList:
        date = status_['date']
        time = status_['time']
        placeName = status_['placeName']
        placeCode = status_['placeCode'];
        data_ =  u"""[最新状況]: %s


[現在位置]: %s %s ([時刻] %s %s )
""" % (status, itemType, slipNo, placeName, placeCode, date, time)
        return data_

if __name__ == '__main__':
    number = input("> ")
    i = GET_status(number)
    print i
OvKNyRgir3BuEJj
Python/C/機械学習
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした