상세 컨텐츠

본문 제목

NAVER 비 로그인 API 호출 python code

IT/AI

by 심장과영혼 2022. 12. 25. 23:44

본문

728x90
반응형
import os
import sys
import urllib.request
client_id = "tSXeMjd9Z85SakWAn3t1-2345"
client_secret = "Xj5KGM4R6-7890t"
encText = urllib.parse.quote("삼성전자")
url = "https://openapi.naver.com/v1/search/blog?query=" + encText # JSON 결과
request = urllib.request.Request(url)
request.add_header("X-Naver-Client-Id",client_id)
request.add_header("X-Naver-Client-Secret",client_secret)
response = urllib.request.urlopen(request)
rescode = response.getcode()
if(rescode==200):
    response_body = response.read()
    print(response_body.decode('utf-8'))
else:
    print("Error Code:" + rescode)
728x90
반응형

관련글 더보기