Yamato Transport's parcel tracking with Python

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

Yamato Transport's parcel tracking with Python
FizzBuzz with Python3
Scraping with Python
Statistics with python
Scraping with Python
Python with Go
Twilio with Python
Integrate with Python
Play with 2016-Python
AES256 with python
Tested with Python
python starts with ()
with syntax (Python)
Bingo with python
Zundokokiyoshi with python
Excel with Python
Microcomputer with Python
Cast with python
GPS tracking with Raspberry Pi 4B + BU-353S4 (Python)
Serial communication with Python
Zip, unzip with python
Django 1.11 started with Python3.6
Primality test with Python
Python with eclipse + PyDev.
Socket communication with Python
Data analysis with python 2
Scraping with Python (preparation)
Try scraping with Python.
Learning Python with ChemTHEATER 03
Sequential search with Python
"Object-oriented" learning with python
Run Python with VBA
Handling yaml with python
Solve AtCoder 167 with python
Serial communication with python
[Python] Use JSON with Python
Learning Python with ChemTHEATER 05-1
Learn Python with ChemTHEATER
Run prepDE.py with python3
1.1 Getting Started with Python
Collecting tweets with Python
Binarization with OpenCV / Python
3. 3. AI programming with Python
Kernel Method with Python
Non-blocking with Python + uWSGI
Scraping with Python + PhantomJS
Posting tweets with python
Drive WebDriver with python
Use mecab with Python3
[Python] Redirect with CGIHTTPServer
Voice analysis with python
Think yaml with python
Operate Kinesis with Python
Getting Started with Python
Use DynamoDB with Python
Zundko getter with python
Handle Excel with python
Ohm's Law with Python
Primality test with python
Run Blender with python
Solve Sudoku with Python