AI_NaverShopping_API - 100-hours-a-week/16-Hot6-wiki GitHub Wiki
Naver์์ ์ ๊ณตํ๋ ๊ฒ์ API๋ฅผ ํตํด ์ถ์ฒ ์์ดํ ๊ฐ๊ฒฉ, ๋งํฌ, ์ด๋ฏธ์ง๋ฅผ return ํ ์ ์๋ค.
์์ ์ฝ๋
import requests
import json
# ๋ค์ด๋ฒ API ์ธ์ฆ ์ ๋ณด
client_id = "..." # โ ์ฌ๊ธฐ์ ๋ณธ์ธ์ Client ID
client_secret = "..." # โ ์ฌ๊ธฐ์ ๋ณธ์ธ์ Client Secret
# ํ
์คํธ์ฉ ์ถ์ฒ ์์ดํ
๋ฆฌ์คํธ
recommended_items = [
"๋ง์ฐ์ค",
"๋ฐ์คํฌ ๋งคํธ",
"๊ธฐ๊ณ์ ํค๋ณด๋",
"๋ฌด์ ์ถฉ์ ๊ธฐ",
"ํ์์ฉ ๋ฏธ๋ ์๋ฌผ"
]
def clean_html(raw_html):
"""<b> ๊ฐ์ HTML ํ๊ทธ ์ ๊ฑฐ"""
clean = re.compile('<.*?>')
return re.sub(clean, '', raw_html)
def extract_categories(item):
# ๊ฐ๋ฅํ ์นดํ
๊ณ ๋ฆฌ ์ ๋ณด ์ถ์ถ
cat2 = item.get("category2", "")
cat3 = item.get("category3", "")
cat4 = item.get("category4", "")
# ํ์ 2๊ฐ ์นดํ
๊ณ ๋ฆฌ ์ ํ ๋ก์ง
if cat4:
return cat3, cat4
elif cat3:
return cat2, cat3
else:
return "", cat2
def search_naver_shop(query, display=3):
url = "https://openapi.naver.com/v1/search/shop.json"
headers = {
"X-Naver-Client-Id": client_id,
"X-Naver-Client-Secret": client_secret
}
params = {
"query": query,
"display": display
}
response = requests.get(url, headers=headers, params=params)
if response.status_code == 200:
return response.json()["items"]
else:
print(f"โ Error {response.status_code}: {response.text}")
return []
# ๊ฒฐ๊ณผ ์์ง
search_results = {}
for item in recommended_items:
results = search_naver_shop(item)
enriched_results = []
for i, product in enumerate(results):
title = clean_html(product["title"])
mall = product.get("mallName", "Unknown")
cat3, cat4 = extract_categories(product)
enriched_results.append({
"title": title,
"price": f"{product['lprice']}์",
"mall": mall,
"category3": cat3,
"category4": cat4,
"link": product["link"],
"image": product["image"]
})
search_results[item] = enriched_results
initial_url = "https://bucket.s3.amazonaws.com/images/12.png"
processed_url = "https://bucket.s3.amazonaws.com/images/123.png"
final_result = {
"initial_image_url": initial_url,
"processed_image_url": processed_url,
**search_results # ๊ธฐ์กด ์์ดํ
๊ฒ์ ๊ฒฐ๊ณผ ์ถ๊ฐ
}
print(json.dumps(final_result, indent=2, ensure_ascii=False))
์ถ๋ ฅ ๊ฒฐ๊ณผ
{
"initial_image_url": "https://bucket.s3.amazonaws.com/images/12.png",
"processed_image_url": "https://bucket.s3.amazonaws.com/images/123.png",
"๋ง์ฐ์ค": [
{
"title": "๋ก์งํ
๋ก์งํ
G G102 2์ธ๋ LIGHTSYNC ๋ธ๋",
"price": "21990์",
"mall": "๋ค์ด๋ฒ",
"category3": "๋ง์ฐ์ค",
"category4": "์ ์ ๋ง์ฐ์ค",
"link": "https://search.shopping.naver.com/catalog/52821285480",
"image": "https://shopping-phinf.pstatic.net/main_5282128/52821285480.20250219134240.jpg"
},
{
"title": "๋ก์งํ
MX MASTER 3S ๊ทธ๋ํ์ดํธ",
"price": "129890์",
"mall": "๋ค์ด๋ฒ",
"category3": "๋ง์ฐ์ค",
"category4": "๋ฌด์ ๋ง์ฐ์ค",
"link": "https://search.shopping.naver.com/catalog/52648750882",
"image": "https://shopping-phinf.pstatic.net/main_5264875/52648750882.20250124152551.jpg"
},
{
"title": "๋ก์งํ
์๊ทธ๋์ฒ M650 ๊ทธ๋ํ์ดํธ",
"price": "38670์",
"mall": "๋ค์ด๋ฒ",
"category3": "๋ง์ฐ์ค",
"category4": "๋ฌด์ ๋ง์ฐ์ค",
"link": "https://search.shopping.naver.com/catalog/52649429437",
"image": "https://shopping-phinf.pstatic.net/main_5264942/52649429437.20250124164326.jpg"
}
],
"๋ฐ์คํฌ ๋งคํธ": [
{
"title": "์นด์ด์ ์ค ๋ฐ์ค์ปค ํธํ ์ฑ
์๋งคํธ ๋ณดํธ์ปค๋ฒ DSK-6(1100x590)",
"price": "19960์",
"mall": "KAIZENS",
"category3": "๋ฐ์คํฌ์ฉํ",
"category4": "๋ฐ์คํฌํจ๋",
"link": "https://smartstore.naver.com/main/products/6195178550",
"image": "https://shopping-phinf.pstatic.net/main_8373967/83739678127.2.jpg"
},
{
"title": "๊ตญ๋ด์ฐ ๋ฐ์คํฌ ๋งคํธ ๊ฐ์ฃฝ ๋ฐ์คํฌ ํจ๋ ์ฑ
์ ๋ฎ๊ฐ ๊นํ ๋ง์ถค ์ ์",
"price": "15900์",
"mall": "์๋น๋์คํ",
"category3": "๋ฐ์คํฌ์ฉํ",
"category4": "๋ฐ์คํฌํจ๋",
"link": "https://smartstore.naver.com/main/products/10529609411",
"image": "https://shopping-phinf.pstatic.net/main_8807411/88074114771.jpg"
},
{
"title": "์์ด๋ ๋ฐ์คํฌ๋งคํธ ๋
ผ์ฌ๋ฆฝ ์ฑ
์ ํจ๋ ์ปค๋ฒ ๋ฎ๊ฐ ๋ณดํธ ๊นํ ๊น๊ฐ ๋ฒ ์ด์ง๋ฐ์ด",
"price": "11900์",
"mall": "ํ ๋น๋ฉ๋ชจ๋ฆฌ",
"category3": "๋ฐ์คํฌ์ฉํ",
"category4": "๋ฐ์คํฌํจ๋",
"link": "https://smartstore.naver.com/main/products/2456322230",
"image": "https://shopping-phinf.pstatic.net/main_1336082/13360829096.2.jpg"
}
],
"๊ธฐ๊ณ์ ํค๋ณด๋": [
{
"title": "ํคํฌ๋ก K10 PRO SE2 ๋ ํธ๋ก ๋ฌด์ ๊ธฐ๊ณ์ ํค๋ณด๋ ์ ํ ๋งฅ ๋ธ๋ฃจํฌ์ค ์ ์์ ๋ฐ๋๋์ถ",
"price": "119000์",
"mall": "ํคํฌ๋ก ๊ณต์์คํ ์ด",
"category3": "ํค๋ณด๋",
"category4": "๋ฌด์ ํค๋ณด๋",
"link": "https://smartstore.naver.com/main/products/10310833443",
"image": "https://shopping-phinf.pstatic.net/main_8785533/87855337549.17.jpg"
},
{
"title": "AULA F87Pro ์ ๋ฌด์ ๋
๊ฑฐ๋ฏธ ํ๊ธ ๊ธฐ๊ณ์ ํค๋ณด๋ ํํค์ค ๊ตญ๋ด ์ ํ ์ฌ๋ฆฌ๋น์ ํ์ดํธ, ํ๋ชฉ์ถ V4",
"price": "62000์",
"mall": "์ง์ค์ผ์ด์๋ฃจ์
",
"category3": "ํค๋ณด๋",
"category4": "์ ์ ํค๋ณด๋",
"link": "https://smartstore.naver.com/main/products/10533419896",
"image": "https://shopping-phinf.pstatic.net/main_8807792/88077925257.jpg"
},
{
"title": "๊ทธ๋ฃจ๋ธ์คํค GV10 ์์ ํ์คํ 104ํค ์ ์ ๊ธฐ๊ณ์ํค๋ณด๋ ํด๋ผ๋ฆฌ์จP GA ์ ์์๋ฐํค์ถ 38g",
"price": "164000์",
"mall": "์ํค WHATKEY",
"category3": "ํค๋ณด๋",
"category4": "์ ์ ํค๋ณด๋",
"link": "https://smartstore.naver.com/main/products/10392743950",
"image": "https://shopping-phinf.pstatic.net/main_8793724/87937248809.10.jpg"
}
],
"๋ฌด์ ์ถฉ์ ๊ธฐ": [
{
"title": "QI2 ๊ฐค๋ญ์ ์์น ์์ดํฐ ๊ณ ์ ๋ฌด์ ์ถฉ์ ๊ธฐ ์ ํ ๋งฅ์ธ์ดํ ์ถฉ์ 3IN1 ๊ฑฐ์น๋",
"price": "46900์",
"mall": "๋
ธ์กด",
"category3": "ํด๋ํฐ์ถฉ์ ๊ธฐ",
"category4": "์ถฉ์ ๊ธฐ",
"link": "https://smartstore.naver.com/main/products/10765675747",
"image": "https://shopping-phinf.pstatic.net/main_8831018/88310181737.1.jpg"
},
{
"title": "์ผ์ฑ ์ค๋งํธ ์ฑ์ค ์คํ
์ด์
(25W ์ด๊ณ ์ ์ถฉ์ ๊ธฐ+1.8M์ผ์ด๋ธ+๊ฐค๋ญ์ ๊ณ ์ ๋ฌด์ ์ถฉ์ ๊ธฐ)",
"price": "58900์",
"mall": "์ผ์ฑ๊ณต์ํํธ๋ dmac",
"category3": "ํด๋ํฐ์ถฉ์ ๊ธฐ",
"category4": "์ถฉ์ ๊ธฐ",
"link": "https://smartstore.naver.com/main/products/7933047617",
"image": "https://shopping-phinf.pstatic.net/main_8547754/85477547940.9.jpg"
},
{
"title": "๋ง๋ ๋งฅ์ธ์ดํ ์ถฉ์ ๊ธฐ ์ ํ์์น 3in1 ๋ฌด์ ์ถฉ์ ๊ธฐ ์์ดํฐ16 ํธํ",
"price": "32900์",
"mall": "manlab. ๋ง๋ ๊ณต์๋ชฐ",
"category3": "ํด๋ํฐ์ถฉ์ ๊ธฐ",
"category4": "์ถฉ์ ๊ธฐ",
"link": "https://smartstore.naver.com/main/products/6207554973",
"image": "https://shopping-phinf.pstatic.net/main_8375205/83752054550.13.jpg"
}
],
"ํ์์ฉ ๋ฏธ๋ ์๋ฌผ": [
{
"title": "ํํฌ์ฑ๊ณ ๋์ ๊ณต๊ธฐ์ ํ์๋ฌผ ํ์์ฉ ๋ฏธ๋ํ๋ถ",
"price": "17000์",
"mall": "๋์ํ๋ํธ",
"category3": "์์/์๋ฌผ",
"category4": "๊ณต๊ธฐ์ ํ์๋ฌผ",
"link": "https://smartstore.naver.com/main/products/5922645777",
"image": "https://shopping-phinf.pstatic.net/main_8346714/83467145265.jpg"
},
{
"title": "ํธํ
๋ฆฌ์ค ํ์์๋ฌผ ํ์์ฉ ๋ฏธ๋์ด์ํ๊ฐ์ต๊ธฐ ๋ํ๊ฐ์ต๊ธฐ ๋ณ์์ฉ",
"price": "26330์",
"mall": "๋ง์ด์ฌ๋ํผํผ",
"category3": "์์/์๋ฌผ",
"category4": "๊ณต๊ธฐ์ ํ์๋ฌผ",
"link": "https://smartstore.naver.com/main/products/10277803462",
"image": "https://shopping-phinf.pstatic.net/main_8782230/87822307286.jpg"
},
{
"title": "๊ฝ๋ค๋ฐ ์ ์ ์ธ๊ณต ์คํ ์ฅ์ ์จ๋ฉ ์๋ฌผ ๋ฏธ๋ ํ์ ์๋ฎฌ๋ ์ด์
Cm blue 1PC",
"price": "36000์",
"mall": "Hazelfive",
"category3": "์์/์๋ฌผ",
"category4": "๊ณต๊ธฐ์ ํ์๋ฌผ",
"link": "https://smartstore.naver.com/main/products/11691717130",
"image": "https://shopping-phinf.pstatic.net/main_8923622/89236227597.jpg"
}
]
}
์์ธ ํ๋ชฉ์ผ๋ก ์ถ๋ ฅ ์์ ("๋ง์ฐ์ค" ๋์ "๋ก์งํ MX Master 3S"๋ก ๊ฒ์ ๋ฑ)
{
"initial_image_url": "https://bucket.s3.amazonaws.com/images/12.png",
"processed_image_url": "https://bucket.s3.amazonaws.com/images/123.png",
"BenQ WiT MindDuo": [
{
"title": "๋ฒคํ WiT MindDuo 2 ์์ด์ผ์ด LED ์คํ ๋ ๋ธ๋ฃจ",
"price": "454900์",
"mall": "์ฟ ํก",
"category3": "์คํ ๋",
"category4": "LED์คํ ๋",
"link": "https://link.coupang.com/re/PCSNAVERPCSDP?pageKey=8398417399&ctag=8398417399&lptag=I24276001921&itemId=24276001921&vendorItemId=91292415249&spec=10305199",
"image": "https://shopping-phinf.pstatic.net/main_5117155/51171550500.jpg"
},
{
"title": "๋ฒคํ WiT MindDuo 2 ์์ด์ผ์ด LED ์คํ ๋ ํ์ดํธ",
"price": "454900์",
"mall": "์ฟ ํก",
"category3": "์คํ ๋",
"category4": "LED์คํ ๋",
"link": "https://link.coupang.com/re/PCSNAVERPCSDP?pageKey=8398417399&ctag=8398417399&lptag=I24276002731&itemId=24276002731&vendorItemId=91292415675&spec=10305199",
"image": "https://shopping-phinf.pstatic.net/main_5108538/51085388217.jpg"
},
{
"title": "๋ฒคํ WiT MindDuo 2 ์์ด์ผ์ด LED ์คํ ๋ ๋ธ๋ฃจ",
"price": "426780์",
"mall": "๋กฏ๋ฐON",
"category3": "์คํ ๋",
"category4": "LED์คํ ๋",
"link": "https://www.lotteon.com/p/product/LO2375102242?sitmNo=LO2375102242_2375102243&ch_no=100065&ch_dtl_no=1000030&entryPoint=pcs&dp_infw_cd=CHT",
"image": "https://shopping-phinf.pstatic.net/main_5084900/50849007780.jpg"
}
],
"Orbitkey Desk Mat": [
{
"title": "์ค๋นํค ๋ฐ์คํฌ ๋งคํธ (L) ์คํค ORBITKEY Desk Mat (L) Stone",
"price": "135000์",
"mall": "์ํฌ์ค๋ธ๋์์ธ",
"category3": "๋ฐ์คํฌ์ฉํ",
"category4": "๋ฐ์คํฌํจ๋",
"link": "https://smartstore.naver.com/main/products/5292664919",
"image": "https://shopping-phinf.pstatic.net/main_8283715/82837157158.1.jpg"
},
{
"title": "์ค๋นํค ๋ฐ์คํฌ๋งคํธ ๋ผ์ง(L) (2์์)",
"price": "135000์",
"mall": "FRAME",
"category3": "๋ฐ์คํฌ์ฉํ",
"category4": "๋ฐ์คํฌํจ๋",
"link": "http://f-rame.com/deskmat/?idx=535",
"image": "https://shopping-phinf.pstatic.net/main_2534456/25344564388.1.jpg"
},
{
"title": "์ค๋นํค ๋ฐ์คํฌ๋งคํธ ์ฌ๋ฆผ(Slim) (2์์)",
"price": "110000์",
"mall": "FRAME",
"category3": "๋ฐ์คํฌ์ฉํ",
"category4": "๋ฐ์คํฌํจ๋",
"link": "http://f-rame.com/deskmat/?idx=1024",
"image": "https://shopping-phinf.pstatic.net/main_4070537/40705372107.jpg"
}
],
"๋ก์งํ
MX Master 3S": [
{
"title": "๋ก์งํ
MX MASTER 3S ๊ทธ๋ํ์ดํธ",
"price": "129890์",
"mall": "๋ค์ด๋ฒ",
"category3": "๋ง์ฐ์ค",
"category4": "๋ฌด์ ๋ง์ฐ์ค",
"link": "https://search.shopping.naver.com/catalog/52648750882",
"image": "https://shopping-phinf.pstatic.net/main_5264875/52648750882.20250124152551.jpg"
},
{
"title": "๋ก์งํ
MX MASTER 3S FOR MAC ํ์ผ๊ทธ๋ ์ด",
"price": "134690์",
"mall": "๋ค์ด๋ฒ",
"category3": "๋ง์ฐ์ค",
"category4": "๋ฌด์ ๋ง์ฐ์ค",
"link": "https://search.shopping.naver.com/catalog/52778703162",
"image": "https://shopping-phinf.pstatic.net/main_5277870/52778703162.20250203110506.jpg"
},
{
"title": "(๋ก์งํ
์ ํ) ๋ก์งํ
MX MASTER 3S ๋ฌด์ ๋ง์ฐ์ค ๊ทธ๋ํ์ดํธ",
"price": "119790์",
"mall": "Aend",
"category3": "๋ง์ฐ์ค",
"category4": "๋ฌด์ ๋ง์ฐ์ค",
"link": "https://smartstore.naver.com/main/products/11551656571",
"image": "https://shopping-phinf.pstatic.net/main_8909616/89096166977.jpg"
}
],
"Anker ๋ฌด์ ์ถฉ์ ๊ธฐ": [
{
"title": "์ค์ปค ANKER ํ๋ผ์ ์ถฉ์ ์คํ
์ด์
100W A1902 ๋ธ๋",
"price": "67910์",
"mall": "๋ค์ด๋ฒ",
"category3": "ํด๋ํฐ์ถฉ์ ๊ธฐ",
"category4": "์ถฉ์ ๊ธฐ",
"link": "https://search.shopping.naver.com/catalog/52420939652",
"image": "https://shopping-phinf.pstatic.net/main_5242093/52420939652.20250113154531.jpg"
},
{
"title": "์ค์ปค ANKER 3in1 ํ๋ธ ๋งฅ์ธ์ดํ ์ฌ์ธ์ ๋ฌด์ ์ถฉ์ ๊ธฐ Y1811 ๊ทธ๋ ์ด",
"price": "159200์",
"mall": "๋ค์ด๋ฒ",
"category3": "ํด๋ํฐ์ถฉ์ ๊ธฐ",
"category4": "์ถฉ์ ๊ธฐ",
"link": "https://search.shopping.naver.com/catalog/52420938636",
"image": "https://shopping-phinf.pstatic.net/main_5242093/52420938636.20250219103442.jpg"
},
{
"title": "์ค์ปค ANKER ํ์์จ์ด๋ธ ๋ง๊ทธ๋คํฑ 2in1 ์คํ ๋ ๋ฌด์ ์ถฉ์ ๊ธฐ A2543 ํ์ดํธ",
"price": "27990์",
"mall": "๋ค์ด๋ฒ",
"category3": "ํด๋ํฐ์ถฉ์ ๊ธฐ",
"category4": "์ถฉ์ ๊ธฐ",
"link": "https://search.shopping.naver.com/catalog/52422454618",
"image": "https://shopping-phinf.pstatic.net/main_5242245/52422454618.20250110141129.jpg"
}
],
"ํ์์ฉ ๋ฏธ๋ ์๋ฌผ": [
{
"title": "ํํฌ์ฑ๊ณ ๋์ ๊ณต๊ธฐ์ ํ์๋ฌผ ํ์์ฉ ๋ฏธ๋ํ๋ถ",
"price": "17000์",
"mall": "๋์ํ๋ํธ",
"category3": "์์/์๋ฌผ",
"category4": "๊ณต๊ธฐ์ ํ์๋ฌผ",
"link": "https://smartstore.naver.com/main/products/5922645777",
"image": "https://shopping-phinf.pstatic.net/main_8346714/83467145265.jpg"
},
{
"title": "ํธํ
๋ฆฌ์ค ํ์์๋ฌผ ํ์์ฉ ๋ฏธ๋์ด์ํ๊ฐ์ต๊ธฐ ๋ํ๊ฐ์ต๊ธฐ ๋ณ์์ฉ",
"price": "26330์",
"mall": "๋ง์ด์ฌ๋ํผํผ",
"category3": "์์/์๋ฌผ",
"category4": "๊ณต๊ธฐ์ ํ์๋ฌผ",
"link": "https://smartstore.naver.com/main/products/10277803462",
"image": "https://shopping-phinf.pstatic.net/main_8782230/87822307286.jpg"
},
{
"title": "๊ฝ๋ค๋ฐ ์ ์ ์ธ๊ณต ์คํ ์ฅ์ ์จ๋ฉ ์๋ฌผ ๋ฏธ๋ ํ์ ์๋ฎฌ๋ ์ด์
Cm blue 1PC",
"price": "36000์",
"mall": "Hazelfive",
"category3": "์์/์๋ฌผ",
"category4": "๊ณต๊ธฐ์ ํ์๋ฌผ",
"link": "https://smartstore.naver.com/main/products/11691717130",
"image": "https://shopping-phinf.pstatic.net/main_8923622/89236227597.jpg"
}
]
}