본문 바로가기

Python_Intermediate/Json

(5)
JSON - Basic 예제 1. URL : http://api.github.com/users/ankiwoong 2. Code import requests res = requests.get('http://api.github.com/users/ankiwoong') print(type(res)) Process finished with exit code 0 import requests res = requests.get('http://api.github.com/users/ankiwoong') text = res.text print(text) {"login":"ankiwoong","id":51388721,"node_id":"MDQ6VXNlcjUxMzg4NzIx","avatar_url":"https://avatars3.githubusercon..
JSON - Data Frame Conversion(Pandas 분석) 1. Sample JSON Site : https://api.androidhive.info/contacts/ 2. Import Moduleimport requests import json from pandas import DataFrame from print_df import print_df 3. Sample Codeimport requests import json from pandas import DataFrame from print_df import print_df url = 'https://api.androidhive.info/contacts' response = requests.get(url) if response.status_code != 200: print("[%d Error] %s" % (r..
JSON - Site JSON data analysis(URL JSON 분석) 1. Import Moduleimport requests import json from print_df import print_df 2. Sample Code- Site URL Response 후 내용 가져와서 출력import requests import json from print_df import print_df url = 'https://api.androidhive.info/contacts' response = requests.get(url) if response.status_code != 200: print("[%d Error] %s" % (response.status_code, response.reason)) quit() response.encoding = 'UTF-8' print_df(resp..
JSON - Types of Data Types / Basic Syntax(데이터 형식의 종류 / 기본 문법) 1. 데이터 형식의 종류 text html XML JSON 형식 텍스트 형식 웹 페이지 화면을 구성하는프로그래밍 언어 다목적 마크업 언어 딕셔너리와 동일한 구조 처리결과 문자열 html 문서(계층적 구조) 요소 또는 특성으로 출력 다른 종류의 언어와 데이터 교환물 출력물 Hello Python Hello Python - Hello Python Hello Python!! {"data": {"item": "Hello Python"}} 2. JSON(JavaScript Object Notation)- 속성-값 쌍( attribute–value pairs and array data types (or any other serializable value)) 또는 "키-값 쌍"으로 이루어진 데이터 오브젝트를 전달하기..
JSON - URL HTTP Connection Basics(HTTP 접속 기초) 1. request 모듈 사용import requests2. 객체 생성import requests response = requests.get('URL')3. 객체 설명response.status_code : 결과 코드를 갖고 있는 변수.(200 - 정상 / 404 - Page Not Found / 500 - 서버에러)response.reason : 에러 메시지를 갖는 변수response.encoding : "utf-8" / "enc-kr" 등을 할당하여 text 속성값의 인코딩을 설정response.text requests : 모듈이 URL에 접속하여 가져온 내용 전문 4. Sample URL : https://api.androidhive.info/contacts 5. Sample Codeimport r..