mmyjh86

[포스코] 네이버 도서 정보 - 2

Sep 14th, 2020
52
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import requests
  2. from pandas import DataFrame
  3.  
  4. def 도서정보조회( 검색어 ):
  5.     client_id = 'your_client_id'
  6.     secret_id = 'your_secret_id'
  7.  
  8.     url = 'https://openapi.naver.com/v1/search/book.json?query=' + 검색어
  9.  
  10.     headers = {
  11.         'X-Naver-Client-Id': client_id,
  12.         "X-Naver-Client-Secret":secret_id
  13.     }
  14.  
  15.     resp = requests.get(url, headers=headers)
  16.     data =  resp.json()
  17.     df = DataFrame( data['items']  )
  18.     return df
  19.  
  20. df = 도서정보조회("파이썬")
  21. print(df.head())
RAW Paste Data