41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
import requests
|
|
class KiprisApiClient:
|
|
def __init__(self, service_key):
|
|
self.service_key = service_key
|
|
self.base_url = "http://plus.kipris.or.kr/"
|
|
|
|
def search_patents(self, word, year, patent, utility, numOfRows=30, pageNo=1):
|
|
params = {
|
|
'accessKey': self.service_key,
|
|
'word': word,
|
|
'year': year,
|
|
'patent': str(patent).lower(),
|
|
'utility': str(utility).lower(),
|
|
'numOfRows': numOfRows,
|
|
'pageNo': pageNo
|
|
}
|
|
response = requests.get(self.base_url, params=params)
|
|
return response.json()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
# API 키와 검색하고자 하는 단어 설정
|
|
service_key = '/loM8C4yXZsTLAmp7PLoq2UCl5zg/OFhZCibzO/D968='
|
|
word = '스키에이트'
|
|
client = KiprisApiClient(service_key)
|
|
|
|
# API 호출 예제
|
|
# word = '전자회로'
|
|
year = '0' # 검색 년도 범위
|
|
patent = True
|
|
utility = False
|
|
numOfRows = 30
|
|
pageNo = 1
|
|
|
|
result = client.search_patents(word, year, patent, utility, numOfRows, pageNo)
|
|
if 'items' in result:
|
|
for item in result['items']:
|
|
print(f"발명의 명칭: {item['inventionTitle']}, 등록번호: {item['registerNumber']}")
|
|
else:
|
|
print("검색 결과가 없습니다.")
|