fix: correct OtherChannels URLs — Google Maps, Naver Blog, Naver Place

Google Maps: was using gm.website (clinic's own site) → now always
generates maps.google.com/search URL

Naver Blog: was linking to first search result post (random personal
blog) → now links to Naver blog search results page

Naver Place: np.link was the clinic's own website, not Naver Place →
now generates map.naver.com search URL. Also fixed collect-channel-data
to search with "성형외과" suffix and match by category (성형/피부) to
avoid same-name dental clinics.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Haewon KamandClaude Opus 4.6 committed 2026-04-04 21:25:26 +09:00
1 parent a02c83155e
commit 29c1faf49e
2 files changed
+35 -14

No files matched your search

@@ -247,17 +247,34 @@ Deno.serve(async (req) => {
})());
tasks.push((async () => {
const query = encodeURIComponent(clinicName);
const res = await fetch(`https://openapi.naver.com/v1/search/local.json?query=${query}&display=5&sort=comment`, { headers: naverHeaders });
if (!res.ok) return;
const data = await res.json();
const place = (data.items || [])[0];
if (place) {
channelData.naverPlace = {
name: (place.title || "").replace(/<[^>]*>/g, ""),
category: place.category, address: place.roadAddress || place.address,
telephone: place.telephone, link: place.link, mapx: place.mapx, mapy: place.mapy,
};
// Try multiple queries to find the correct place (avoid same-name different clinics)
const queries = [
`${clinicName} 성형외과`,
`${clinicName} 성형`,
clinicName,
];
for (const q of queries) {
const query = encodeURIComponent(q);
const res = await fetch(`https://openapi.naver.com/v1/search/local.json?query=${query}&display=5&sort=comment`, { headers: naverHeaders });
if (!res.ok) continue;
const data = await res.json();
// Find the best match: prefer category containing 성형 or 피부
const items = (data.items || []) as Record<string, string>[];
const match = items.find(i =>
(i.category || '').includes('성형') || (i.category || '').includes('피부')
) || items.find(i => {
const name = (i.title || '').replace(/<[^>]*>/g, '').toLowerCase();
return name.includes(clinicName.replace(/성형외과|병원|의원/g, '').trim().toLowerCase());
}) || null;
if (match) {
channelData.naverPlace = {
name: (match.title || "").replace(/<[^>]*>/g, ""),
category: match.category, address: match.roadAddress || match.address,
telephone: match.telephone, link: match.link, mapx: match.mapx, mapy: match.mapy,
};
break;
}
}
})());
}