티스토리 뷰

 

 

import requests
import json

class cNaverAPI_Search:

    def __init__(self):
        pass

    def StartSearch_News(self, keyWord):
        maxDisplay = 100
        url = "https://openapi.naver.com/v1/search/news?"+'display='+str(maxDisplay)
        clientId = 'ID'
        clientSecret = 'SECRET'
        queryString = '&query='+keyWord
        header = {
            'X-Naver-Client-Id':clientId,
            'X-Naver-Client-Secret':clientSecret
        }

        response = requests.get(url+queryString, headers=header)
        jsonDicts = response.json()
        #print(jsonDicts.keys())
        #print(jsonDicts.values())
        for item1 in jsonDicts['items']:
            print(item1['title'])


        #print(json.loads(r.text))
반응형
반응형
250x250
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/01   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함