devkingsejong / python-powernad Goto Github PK
View Code? Open in Web Editor NEWNaver search Ad Lib for Python
Naver search Ad Lib for Python
부디 확인해주셨으면...
파이썬 배운지 얼마 되지 않아 모르는 것이 많습니다.
get_stat_by_id
를 쓰려고 하는데,
네이버 가이드와 다른 점이 몇가지 있고, 안되는 것이 있어 말씀드립니다. ㅠㅠ
get_stat_by_id 의 파라미터를 보면, id, fields 는 꼭 기입해야하고,
timeRange 나 datePreset 은 둘 중 하나만 기입해도 작동한다고 하는데,
timeRange 를 정의하지 않으면 무조건 에러가 납니다.
또, datePreset 오타가 있는 것같네요.
네이버에선 datePreset 이라고 되어있는데 Stat.py 를 보니 dataPreset 이라고 되어있습니다.
date -> data 이렇게요. 뭐 오타는 크게 상관이 없지만,
이놈의 timeRange 형식을 대체 어떻게 써야할지 모르겠습니다.
네이버 예제로는
{"since":"YYYY-MM-DD","until":"YYYY-MM-DD"}
이렇게 되어있어서
st = statinfo.get_stat_by_id(id = 'nkw-a001-01-xxxxxxxxxxxxxx', fields = 'avgRnk', timeRange = {"since":"2020-05-25","until":"2020-05-26"})
이런식으로 해봤는데,
quote_from_bytes() expected bytes
이런 에러가 나구요,
말씀드렸다시피 timeRange 를 무조건 써야하기 때문에 datePreset 은 사용하나 마나구요. ㅠㅠ
어떻게 해결이 안될까요...?
매일 와서 답변 기다리겠습니다. ㅠㅠ
다름이 아니라 최근 한달이 아니라 2달 전이나 3달 전 데이터는 알수없는걸까요...?
임포트가 안되네요 혹시 파이썬 3.7 버전이라서 그런가요?ㅠ
from powernad.API import RelKwdStat
Traceback (most recent call last):
File "", line 1, in
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/powernad/API/RelKwdStat.py", line 1, in
from powernad.Connector.restapi import RestApi
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/powernad/Connector/restapi.py", line 7, in
import requests
ModuleNotFoundError: No module named 'requests'
안녕하세요 PowerNad 모듈 너무 잘 사용하고 있습니다 !
덕분에 키워드 데이터를 크롤링할 수 있게 됐습니다. 너무 감사합니다 :)
한가지 여쭤보고 싶어 글 남기는데요.
혹시 키워드 데이터가 최근 한달 데이터인데, 일일 데이터도 갖고 올 수 있는 법이 있을까요?
API를 활용하면 가능할까 싶어 여쭤봅니다 :)
감사합니다!
소재 등록시 예제에서
filed_obj.pc = filed_obj.make_pc_easy('http://www.naver.com')
이런식으로 되어 있는데요. 네이버 쇼핑몰 의 특정 상품으로 등록시키고 싶으면 full url을 사용하면 되나요?
filed_obj.pc = filed_obj.make_pc_easy('https://smartstore.naver.com/kimschain/products/5007533437")
이런식으로요?
소재가 의미하는게 노출하고 싶은 url로 이해하면 될까요?
파이썬 공부 한지 3주 된 초보인데, 쇼핑몰 운영중이여서 키워드 조회수좀 뽑아 볼려고 코드 작성 하는데
from powernad.API.RelKwdStat import *
from powernad.Object.RelKwdStat import *
from powernad.Connector.restapi import *
a = RelKwdStat("https://api.naver.com/", "01000000005d281e90c8b62d8399bf688779ce923a207e17d539d4e7fadf38d61e7931e387", "AQAAAABdKB6QyLYtg5m/aId5zpI6Utbqk6sXUqcNnFmO3Mzu8w==", 466861)
test = a.get_rel_kwd_stat_list('bsn-a001-00-000000000133921', 20, 'kakao', 1, 1, 1)
=======================================================
안됩니다.ㅠㅠ 혹시 상세한 가이드 부탁드려도 될까요?
한개만 되면 나머지는 될꺼 같은데
부탁좀 드립니다. ㅠㅠ
안녕하세요.
먼저 좋은 모듈을 개발해주셔서 감사드립니다.
다름이 아니라 제가 파이썬 공부를 한 지 얼마 안돼서 찾다 찾다 도저히 모르는 부분이 있어서 글을 남겼습니다. ㅠ
아래와 같이 코드를 짜서 검색량 데이터를 받고 있는데, 혹시 작년 검색량은 받을 수 없을까요?
month를 바꿨는데도, 검색량 수가 똑같네요 ㅠㅠ
작년, 재작년 월별 검색량을 추이를 알고 싶은데 방법이 없을까요?
kwdDataList = rel.get_rel_kwd_stat_list(siteId=None, biztpId=None, hintKeywords=searchword, event=None, month='4', showDetail='1')
kwd_result = (kwdDataList[0].relKeyword,
kwdDataList[0].monthlyPcQcCnt,
kwdDataList[0].monthlyMobileQcCnt,
kwdDataList[0].monthlyPcQcCnt+kwdDataList[0].monthlyMobileQcCnt)
return(kwd_result[3])
import sys
import io
sys.stdout = io.TextIOWrapper(sys.stdout.detach(), encoding = 'utf-8')
sys.stderr = io.TextIOWrapper(sys.stderr.detach(), encoding = 'utf-8')
from powernad.Connector.restapi import RestApi
from powernad.Object.RelKwdStat.RelKwdStatObject import RelKwdStatObject
from typing import List
RelKwdStatObjectList = List[RelKwdStatObject]
class RelKwdStat: #클래스 선언
#클래스 초기화
def init(self, base_url: str, api_key: str, secret_key: str, customer_id: int): #객체 초기화
self.r = RestApi('https://api.naver.com', '0100000' #Constructor 생성자
, 'ABCDE==', 123456) #튜플??
def get_rel_kwd_stat_list(self, siteId: str, biztpId: int = None, hintKeywords: str = None, event: int = None,
month: int = None, showDetail: int = None) -> RelKwdStatObjectList:
#딕셔너리
query = {'siteId': siteId, 'biztpId': biztpId, 'hintKeywords': hintKeywords,
'event': event, 'month': month, 'showDetail': showDetail}
result = self.r.get('/keywordstool', query)
result = result['keywordList'] #리스트
relstat_list = [] #빈 리스트
for arr in result: #반복문
relstat = RelKwdStatObject(arr)
relstat_list.append(relstat)
return relstat_list
import json
class RelKwdStatObject:
def init(self, json_def):
if type(json_def) is str:
json_def = json.loads(json_def)
s = json_def
self.relKeyword = None if 'relKeyword' not in s else s['relKeyword']
self.monthlyPcQcCnt = None if 'monthlyPcQcCnt' not in s else s['monthlyPcQcCnt']
self.monthlyMobileQcCnt = None if 'monthlyMobileQcCnt' not in s else s['monthlyMobileQcCnt']
self.monthlyAvePcClkCnt = None if 'monthlyAvePcClkCnt' not in s else s['monthlyAvePcClkCnt']
self.monthlyAveMobileClkCnt = None if 'monthlyAveMobileClkCnt' not in s else s['monthlyAveMobileClkCnt']
self.monthlyAvePcCtr = None if 'monthlyAvePcCtr' not in s else s['monthlyAvePcCtr']
self.monthlyAveMobileCtr = None if 'monthlyAveMobileCtr' not in s else s['monthlyAveMobileCtr']
self.plAvgDepth = None if 'plAvgDepth' not in s else s['plAvgDepth']
self.compIdx = None if 'compIdx' not in s else s['compIdx']
개발왕세종님께서 알려준 코드 있는대로 붙이고, API 관리센터에서 얻은 정보들 얻고,
코드 입력했는데 응답이 없네요 제가 뭔가 추가로 코드 입력 할게 있을까요??
우선, 저는 개발자는 아니고 분석업무 위주로 수행하는 사람인데, 최근 외부 데이터 확보에 대한 과제가 많아서 크롤링 작업을 하게 되었습니다. (즉 왕초보 입니다..)
네이버광고 - 키워드도구 - 결과데이터(조회수,클릭률등) 수집이 필요했는데 powernad 를 정말 유용하게 활용하고 있습니다. 감사합니다 (꾸벅)
powernad의 RelKwdStat 을 사용하여서 코드 작성 후 ,
1)구글코랩 2)VScode 두가지 환경에서 실행을 해봤는데요 .
구글코랩에서는 결과가 잘 나오는 반면 똑같은 코드를 VScode에서 실행하면 [ 'NoneType' object is not subscriptable ] 에러가 납니다. 혹시 해결방안을 아실까요 ?
(똑같은 코드인데 구글코랩에서 실행하면 잘 돌아가는데요.. 뭘까요 ? 혹시 환경변수 문제일까 PATH 에 Script 경로 추가된 것도 확인 했습니다 ㅜㅜ )
정말 감사합니다 !!
========= 파이썬 코드 =================
import os
import io
import sys
import json
import jsonpickle
import urllib.request
from powernad.API.RelKwdStat import *
import sqlite3
API_CUSTOMER_ID = "API고객ID"
API_ACCESS_LICCENCE = "API라이센스키"
API_SECRET_KEY = "API시크릿키"
API_URL = "https://api.naver.com"
rel = RelKwdStat(API_URL, API_ACCESS_LICCENCE, API_SECRET_KEY, API_CUSTOMER_ID)
searchword="샴푸"
kwdDataList = rel.get_rel_kwd_stat_list(siteId=None, biztpId=None, hintKeywords=searchword, event=None, month=None, showDetail='1')
kwd_result = (kwdDataList[0].relKeyword,
kwdDataList[0].monthlyPcQcCnt,
kwdDataList[0].monthlyMobileQcCnt,
kwdDataList[0].monthlyAvePcClkCnt,
kwdDataList[0].monthlyAveMobileClkCnt,
kwdDataList[0].monthlyAvePcCtr,
kwdDataList[0].monthlyAveMobileCtr,
kwdDataList[0].plAvgDepth,
kwdDataList[0].compIdx
)
print(kwd_result)
========= 에러메세지 =================
failed to request
Traceback (most recent call last):
File "practice.py", line 26, in
kwdDataList = rel.get_rel_kwd_stat_list(siteId=None, biztpId=None, hintKeywords=searchword, event=None, month=None, showDetail='1')
File "C:\Users\brightchung2\AppData\Local\Programs\Python\Python38\lib\site-packages\powernad\API\RelKwdStat.py", line 18, in get_rel_kwd_stat_list
result = result['keywordList']
TypeError: 'NoneType' object is not subscriptable
PS D:\Cheongah\programming\python\crawling\Searchad>
파이썬 완전 초짜인데요..ㅠㅠ
"A"라는 키워드를 검색했을때
모바일 pc 검색조회량을 알아보는 코드를 만들고 싶은데 어떤 코드를 짜야할지 모르게가지구요 ㅠㅠ
혹시 조언좀해주실수 있으실까요?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.