라일락 꽃이 피는 날

[Python] Open API 본문

프로그래밍/Python

[Python] Open API

eunki 2021. 8. 22. 11:23
728x90

공공데이터 포털 OPEN API 사용하기

 

  1. 공공데이터 포털 로그인 (https://www.data.go.kr/)
  2. API 사용 요청 / 키 발급
  3. API 문서(specification) 확인
  4. API 테스트 및 개발
import requests

serviceKey = 'serviceKey123'
endpoint = 'http://api.visitkorea.or.kr/openapi/service/rest/EngService/areaCode?serviceKey={}&numOfRows=10&pageSize=10&pageNo={}&MobileOS=ETC&MobileApp=AppTest&_type=json'.format(serviceKey, 1)
resp = requests.get(endpoint)

data = resp.json()
print(data['response']['body']['items']['item'][0])  # {'code': 1, 'name': 'Seoul', 'rnum': 1}
728x90

'프로그래밍 > Python' 카테고리의 다른 글

[Python] selenium  (0) 2021.08.22
[Python] BeautifulSoup  (0) 2021.08.22
[Python] requests  (0) 2021.08.22
[Python] 정규 표현식 (regular expression) 2  (0) 2021.08.16
[Python] 정규 표현식 (regular expression) 1  (0) 2021.08.16