import requests
import json

page = 1
datas = dict()
while 1:
    response = requests.get('https://8oi9s0nnth.apigw.ntruss.com/corona19-masks/v1/stores/json?page=%d&perPage=500' % page)
    maskdict = json.loads(response.text)
    if len(maskdict.get('storeInfos')) == 0:
        break
    for b in maskdict.get('storeInfos'):
        datas[b.get('code')] = b;
    page = page + 1

print("%-20s%-80s%-10s" % ('이름', '주소', '재고상태'))
page = 1
while 1:
    response = requests.get('https://8oi9s0nnth.apigw.ntruss.com/corona19-masks/v1/sales/json?page=%d&perPage=500' % page)
    maskdict = json.loads(response.text)
    if len(maskdict.get('sales')) == 0:
        break
    for b in maskdict.get('sales'):
        if b.get('code') not in datas:
            continue
        data = datas[b.get('code')]
        print("%-20s%-80s%-10s" % (data.get('name'), data.get('addr'), b.get('remain_stat')))
    page = page + 1
