๐ Google Apps Script ์ค์๊ฐ ๊ฒฝ์ ํฐ์ปค ๋ฐฐํฌ ์์ ์์ธ ๊ฐ์ด๋
(2025๋ 11์ 28์ผ ๊ธฐ์ค, ์คํฌ๋ฆฐ์ท ์์ด๋ 100% ์ฑ๊ณตํ๋ ์์)
์ด ๊ฐ์ด๋๋ Google Apps Script๋ฅผ ์น ์ฑ(Web App)์ผ๋ก ๋ฐฐํฌํ์ฌ, Google Trends์ ์ค์๊ฐ ๊ฒฝ์ ํค์๋๋ฅผ ๊ฐ์ ธ์ค๋ JSON API (ํฐ์ปค ๋ฐ์ดํฐ)๋ฅผ ๋ง๋๋ ๊ณผ์ ์ ์์ธํ ์๋ดํฉ๋๋ค. ์ด JSON URL์ ๋ธ๋ก๊ทธ๋ ์น์ฌ์ดํธ์ ์ค์๊ฐ ์ ๋ณด๋ฅผ ํ์ํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค.
1๋จ๊ณ: ์ Apps Script ํ๋ก์ ํธ ๋ง๋ค๊ธฐ
Apps Script ํํ์ด์ง ์ ์:
https://script.google.com/home์ ์ํฉ๋๋ค.
์ ํ๋ก์ ํธ ์์:
์ผ์ชฝ ์ ํ๋ ๋ฒํผ 【+ ์ ํ๋ก์ ํธ】๋ฅผ ํด๋ฆญํฉ๋๋ค.
ํ๋ก์ ํธ ์ด๋ฆ ์ค์ :
ํ๋ก์ ํธ ์ด๋ฆ(์: “๊ฒฝ์ ํฐ์ปค 2025”)์ ์๋ฌด๊ฑฐ๋ ์ ๋ ฅํฉ๋๋ค.
2๋จ๊ณ: ํต์ฌ ์ฝ๋ ์ ์ฒด ๊ต์ฒด ๋ฐ ์ ์ฅ
๊ธฐ์กด Code.gs์ ์๋ ๋ด์ฉ์ ์ ๋ถ ์ง์ฐ๊ณ , ์๋์ ํต์ฌ JavaScript ์ฝ๋๋ฅผ ๋ณต์ฌํ์ฌ ๋ถ์ฌ๋ฃ์ต๋๋ค. ์ด ์ฝ๋๋ Google Trends RSS ํผ๋์์ ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์ ๊ฒฝ์ ๊ด๋ จ ํค์๋๋ง ํํฐ๋งํ ํ, JSON ํ์์ผ๋ก ๋ฐํํ๋ ์ญํ ์ ํฉ๋๋ค.
function doGet(e) {
return ContentService
.createTextOutput(getKoreaEconomyTrends())
.setMimeType(ContentService.MimeType.JSON);
}
function getKoreaEconomyTrends() {
try {
const rss = UrlFetchApp.fetch('https://trends.google.com/trends/trendingsearches/daily/rss?geo=KR').getContentText();
const items = rss.split('<item>');
const result = [];
const keywords = ['์ฝ์คํผ','์ฝ์ค๋ฅ','ํ์จ','๋ฌ๋ฌ','๊ธ๋ฆฌ','๊ธฐ์ค๊ธ๋ฆฌ','๋ถ๋์ฐ','์ํํธ','๋นํธ์ฝ์ธ','์ฝ์ธ','๊ธ๊ฐ','์ ๊ฐ','์ฃผ์','ํฌ์','๊ฒฝ๊ธฐ','๋ฌผ๊ฐ','์ธํ๋ ','์ค์
','๋ฐฐ๋น','IPO','์ฑ๊ถ','์ํ','์ฆ๊ถ','์์ถ','์์
'];
for (let i = 1; i < items.length && result.length < 5; i++) {
const title = items[i].match(/<title><!\[CDATA\[(.*?)\]\]><\/title>/);
if (title) {
const kw = title[1].trim();
if (keywords.some(k => kw.includes(k)) && kw.length > 2) {
result.push({
keyword: kw,
link: 'https://www.google.com/search?q=' + encodeURIComponent(kw) + '&hl=ko&gl=kr'
});
}
}
}
// ๊ฒฝ์ ํค์๋๊ฐ ์์ ๋ ๊ธฐ๋ณธ๊ฐ
if (result.length === 0) {
result.push({keyword:"์ฝ์คํผ",link:"https://google.com/search?q=์ฝ์คํผ"},
{keyword:"ํ์จ",link:"https://google.com/search?q=ํ์จ"},
{keyword:"๊ธ๋ฆฌ",link:"https://google.com/search?q=๊ธ๋ฆฌ"},
{keyword:"๋ถ๋์ฐ",link:"https://google.com/search?q=๋ถ๋์ฐ"},
{keyword:"๋นํธ์ฝ์ธ",link:"https://google.com/search?q=๋นํธ์ฝ์ธ"});
}
return JSON.stringify(result);
} catch (e) {
// ์ค๋ฅ ๋ฐ์ ์ ๊ธฐ๋ณธ๊ฐ ๋ฐํ
return JSON.stringify([
{keyword:"์ฝ์คํผ",link:"https://google.com/search?q=์ฝ์คํผ"},
{keyword:"ํ์จ",link:"https://google.com/search?q=ํ์จ"},
{keyword:"๊ธ๋ฆฌ",link:"https://google.com/search?q=๊ธ๋ฆฌ"},
{keyword:"๋ถ๋์ฐ",link:"https://google.com/search?q=๋ถ๋์ฐ"},
{keyword:"๋นํธ์ฝ์ธ",link:"https://google.com/search?q=๋นํธ์ฝ์ธ"}
]);
}
}
์ ์ฅ: ์ฝ๋๋ฅผ ๋ถ์ฌ๋ฃ์ ํ, ์๋จ์ ๋์คํฌ ๋ชจ์ ์์ด์ฝ์ ํด๋ฆญํ๊ฑฐ๋ Ctrl + S๋ฅผ ๋๋ฌ ์ ์ฅํฉ๋๋ค.
3๋จ๊ณ: ์ ํํ ์น ์ฑ ๋ฐฐํฌ 7์ด ์์ (URL ํ๋)
์ด ์์๋ง ์งํค๋ฉด .../exec๋ก ๋๋๋ ์น ์ฑ URL์ 100% ์ฑ๊ณต์ ์ผ๋ก ์ป์ ์ ์์ต๋๋ค.
๋ฐฐํฌ ์์: ์๋จ ๋ฉ๋ด 【๋ฐฐํฌ】 → 【์ ๋ฐฐํฌ】๋ฅผ ํด๋ฆญํฉ๋๋ค.
๋ฐฐํฌ ์ ํ ์ ํ: ๋ฐฐํฌ ์ค์ ์ฐฝ์ด ๋จ๋ฉด, ์ค๋ฅธ์ชฝ ํฑ๋๋ฐํด ์์ด์ฝ์ ํด๋ฆญํ๊ณ 【์น ์ฑ】์ ์ ํํฉ๋๋ค.
๋ฐฐํฌ ์ค์ ์ ๋ ฅ (๊ฐ์ฅ ์ค์):
์คํ ๋์: ๋ (๋ณธ์ธ ์ด๋ฉ์ผ)
์ก์ธ์ค ๊ถํ: ๋๋กญ๋ค์ด ๋ฉ๋ด๋ฅผ ํด๋ฆญํ์ฌ ▼ ๋๊ตฌ๋(์ต๋ช ํฌํจ)๋ฅผ ์ ํํฉ๋๋ค.
【๋ฐฐํฌ】 ๋ฒํผ์ ํด๋ฆญํฉ๋๋ค.
๊ถํ ์น์ธ (์ต์ด 1ํ ํ์):
“์ฑ์ด ๊ฒ์ฆ๋์ง ์์์ต๋๋ค” ํ๋ฉด์ด ๋จ๋ฉด:
【๊ณ ๊ธ】์ ํด๋ฆญํฉ๋๋ค.
ํ๋ฉด ๋งจ ์๋ 【๊ณ์ํ๊ธฐ(์์ ํ์ง ์์)】๋ฅผ ํด๋ฆญํฉ๋๋ค.
【ํ์ฉ】์ ํด๋ฆญํ์ฌ Apps Script๊ฐ Google ์๋น์ค(RSS URL ํธ์ถ ๋ฑ)๋ฅผ ์ฌ์ฉํ ์ ์๋๋ก ๊ถํ์ ๋ถ์ฌํฉ๋๋ค.
URL ๋ณต์ฌ:
๋ฐฐํฌ๊ฐ ์๋ฃ๋๋ฉด ์น ์ฑ URL์ด ๋ํ๋ฉ๋๋ค.
/exec๋ก ๋๋๋ ์ ์ฒด ์ฃผ์๋ฅผ ๋ณต์ฌํฉ๋๋ค.
์ ์์ ์ธ URL ์์:
https://script.google.com/macros/s/AKfycb...์ฅ๋์๋๊ฒ๊ธดID.../exec
4๋จ๊ณ: ๋ธ๋ก๊ทธ/์น์ฌ์ดํธ์ URL ํตํฉ
๋ณต์ฌํ URL์ ์ค์ ๋ก ๋ฐ์ดํฐ๋ฅผ ํ์ํ ๋ธ๋ก๊ทธ๋ ์น์ฌ์ดํธ์ HTML/JavaScript ์ฝ๋์ ์ ์ฉํฉ๋๋ค.
๋ธ๋ก๊ทธ ํ ๋ง์ HTML ํธ์ง ๋ชจ๋๋ก ์ด๋ํฉ๋๋ค.
์๋ ์ค์ ์ฐพ์์, ๋น์ ์ด ๋ณต์ฌํ
/execURL๋ก ๊ต์ฒดํฉ๋๋ค.
const MY_PROXY = 'https://script.google.com/macros/s/๋น์ ์ด-๋ณต์ฌํ-๊ธด-ID/exec';
์ ์ฅ ํ ๋ธ๋ก๊ทธ๋ฅผ ์๋ก๊ณ ์นจํ์ฌ ์ค์๊ฐ ํฐ์ปค๊ฐ ์๋ํ๋์ง ํ์ธํฉ๋๋ค.
5๋จ๊ณ: ๋ฐฐํฌ ์ฑ๊ณต ์ฌ๋ถ 3์ด ํ ์คํธ
๋ฐฐํฌ๋ URL์ด ์ ์ ์๋ํ๋์ง ๊ฐ์ฅ ๋น ๋ฅด๊ฒ ํ์ธํ๋ ๋ฐฉ๋ฒ์ ๋๋ค.
๋ธ๋ผ์ฐ์ ์ ํญ์ ์ด๊ณ 3๋จ๊ณ์์ ๋ณต์ฌํ
/execURL๋ง ๋ถ์ฌ๋ฃ๊ณ ์ํฐ๋ฅผ ์นฉ๋๋ค.ํ๋ฉด์ ์๋์ ๊ฐ์ด JSON ํ์์ ๋ฐ์ดํฐ๊ฐ ์ถ๋ ฅ๋๋ฉด 100% ์ฑ๊ณต์ ๋๋ค.
[{"keyword":"์ฝ์คํผ 2600","link":"https://www.google.com/search?q=..."},{"keyword":"ํ์จ 1480์",...}]
๐ ๋ง์ฝ "๊ฒ์ฆ๋์ง ์์" ํ๋ฉด์ด ๋ ๋จ๊ฑฐ๋ ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ค๋ฉด?
์ด ๋ฌธ์ ๋ ์ฃผ๋ก ์ก์ธ์ค ๊ถํ์ด "๋"๋ก ์ค์ ๋์ด ์ธ๋ถ์์ ์ ๊ทผ์ด ๋ถ๊ฐ๋ฅํ ๋ ๋ฐ์ํฉ๋๋ค.
【๋ฐฐํฌ】 → 【๋ฐฐํฌ ๊ด๋ฆฌ】๋ก ์ด๋ํฉ๋๋ค.
๋ชฉ๋ก์ ์๋ ๊ธฐ์กด ๋ฒ์ ์์ ์ฐํ ์์ด์ฝ (์์ )์ ํด๋ฆญํฉ๋๋ค.
์ก์ธ์ค ๊ถํ ์ค์ ์ ๋ค์ “๋๊ตฌ๋(์ต๋ช ํฌํจ)”๋ก ๋ณ๊ฒฝํฉ๋๋ค.
【์ ๋ฐ์ดํธ】 ๋ฒํผ์ ํด๋ฆญํฉ๋๋ค.
์ด์ ์ง์ง ๋์ ๋๋ค. ์ด ๊ฐ์ด๋๋๋ก๋ง ํ์๋ฉด ๋๊ตฌ๋ 5๋ถ ์์ ์ค์๊ฐ ๊ฒฝ์ ํฐ์ปค ์์ฑํฉ๋๋ค!
#๊ฐ๋ ํฌ๋ฐ์ด #ganatoday
๊ทธ๋ฆฐ์ํ๋ก