
# coding: utf-8

# #10.31 지하철역 인원(기간)

# In[1]:

def getKey(keyPath):
    d=dict()
    f=open(keyPath,'r')
    for line in f.readlines():
        row=line.split('=')
        row0=row[0]
        d[row0]=row[1].strip()
    return d


# In[2]:

import os

keyPath=os.path.join(os.getcwd(), 'src', 'key.properties')
key=getKey(keyPath)


# In[3]:

key


# In[4]:

import os
import requests
_url = 'http://openAPI.seoul.go.kr:8088'
_key = str(key['dataseoul'])
_type = 'xml'
_service = 'CardSubwayStatisticsService'
_start_index=1
_end_index=5
_use_mon='201306'
_api=(_url+'/'+_key+'/'+_type+'/'+_service+'/'+str(_start_index)+'/'+str(_end_index)+'/'+_use_mon)


# In[5]:

print _api


# In[6]:

_maxIter=2
_iter=0
while _iter<_maxIter:
    response = requests.get(_api).text
    print response
    _start_index+=5
    _end_index+=5
    _iter+=1


# In[ ]:



