Track Yamato Transport packages using Python. The module you are using requests : http://docs.python-requests.org/en/latest/ Only.
This code uses the following API. Thank you for the provider. http://nanoappli.com/blog/archives/603
By the way, this code assumes that the inquiry number is an integer type. If you get a string type etc., you will get a Type-error or something ()
Yamato Transport Luggage Tracking.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"""[Latest status]: %s
[Delivery type]: %s
[Delivery slip number]: %s
[present location]: %s %s ([Times of Day] %s %s )
""" % (status, itemType, slipNo, placeName, placeCode, date, time)
return data_
if __name__ == '__main__':
number = input("> ")
i = GET_status(number)
print i
Recommended Posts