Skip to content
- request 설치(json은 기본으로 설치되어 있음
- CMD에서
- cd \파이썬폴더\Scripts
- pip install requests
- 파이참 terminal에서
- pip install requests
- 역할
- request : 데이터를 요청하는 라이브러리 모듈
- json : JSON 형태의 데이터를 파싱(parsing)하는 라이브러리 모듈
- 네이버 날씨 Json
- https://weather.naver.com/json/crntWetr.nhn
- 전송 데이터
- 소스 코드
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
import requests import json def getJson(url): resp = requests.get(url) html = json.loads(resp.text) lst = [] html = html['wetrMap'] for data in html: if type(data[1]) == dict: lst.append(data[1]) return lst url = 'https://weather.naver.com/json/crntWetr.nhn' rss_list = getJson(url) for rss in rss_list: print(rss) |
error: Content is protected !!