Skip to main content

naver open api for python

Project description

PyNaver

Hits Linkedin Badge

소개

PyNaver는 naver developers에서 제공하는 오픈 API를 이용할 수 있는 Python Client 입니다. PyNaver를 정상적으로 이용하기 위해서는 naver developers 애플리케이션 정보(Client ID, Client Secret)가 필요합니다.

설치

pip install PyNaver

예제

from PyNaver import Datalab
from config import Config

config = Config()
# 네이버 데이터랩 API 클라이언트 ID, SECRET
client_id = config.OPEN_API['naver']['client_id']
client_secret = config.OPEN_API['naver']['client_secret']
# 네이버 데이터랩 API 세션 정의
DL = Datalab(client_id, client_secret)
# 검색어 그룹 세트 정의하기
keyword_group_set = {
    'keyword_group_1': {'groupName': "애플", 'keywords': ["애플","Apple","AAPL"]},
    'keyword_group_2': {'groupName': "아마존", 'keywords': ["아마존","Amazon","AMZN"]},
    'keyword_group_3': {'groupName': "구글", 'keywords': ["구글","Google","GOOGL"]},
    'keyword_group_4': {'groupName': "테슬라", 'keywords': ["테슬라","Tesla","TSLA"]},
    'keyword_group_5': {'groupName': "페이스북", 'keywords': ["페이스북","Facebook","FB"]}
}
# 요청 파라미터 설정
startDate = "2021-01-01"
endDate = "2021-12-31"
timeUnit = 'date'
device = ''
ages = []
gender = ''

# 검색어 그룹 세트 등록하기
DL.add_keyword_groups(keyword_group_set['keyword_group_1'])
DL.add_keyword_groups(keyword_group_set['keyword_group_2'])
DL.add_keyword_groups(keyword_group_set['keyword_group_3'])
DL.add_keyword_groups(keyword_group_set['keyword_group_4'])
DL.add_keyword_groups(keyword_group_set['keyword_group_5'])

# 결과 데이터를 DataFrame으로 조회하기
df = DL.get_data(startDate, endDate, timeUnit, device, ages, gender)
df
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
날짜 애플 아마존 구글 테슬라 페이스북
0 2021-01-01 10.22685 2.71217 81.27609 6.30002 38.51378
1 2021-01-02 10.28149 3.14536 85.91210 5.64883 34.69233
2 2021-01-03 10.23001 3.13477 91.73209 6.96682 34.85066
3 2021-01-04 13.48651 3.64769 97.28281 9.36343 36.27848
4 2021-01-05 15.03680 3.70047 97.39134 12.24063 35.20878
... ... ... ... ... ... ...
360 2021-12-27 7.39872 2.34624 81.16979 4.71256 21.63808
361 2021-12-28 8.32198 2.56219 80.33258 6.80532 21.85681
362 2021-12-29 8.02667 2.82813 80.21513 6.52192 21.60685
363 2021-12-30 7.69216 2.42225 77.53213 5.97313 21.34798
364 2021-12-31 6.75645 2.10874 71.91340 5.12922 21.17217

365 rows × 6 columns

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyNaver-0.0.1.tar.gz (4.9 kB view hashes)

Uploaded Source

Built Distribution

PyNaver-0.0.1-py3-none-any.whl (5.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page