AI[ rssํผ๋][๋ด์คํฌ๋กค๋ฌ][API ์ํ์ ๊ฒ] [๋ฐ์ดํฐ๊ฒ์ฆ ์์คํ ]
๋ชฉ์ฐจ
1. RSS ํผ๋ ๋ชจ๋ํฐ๋ง ์์คํ
์ฃผ์ AI ๊ด๋ จ RSS ํผ๋๋ฅผ ์ค์๊ฐ์ผ๋ก ๋ชจ๋ํฐ๋งํ๋ ์์คํ ์ ๋๋ค.
const feedparser = require('feedparser-promised');
async function monitorRSSFeeds() {
const feeds = [
'https://blog.google/technology/ai/rss/',
'https://openai.com/blog/rss/',
'https://news.mit.edu/rss/topic/artificial-intelligence'
];
try {
for (const feed of feeds) {
const items = await feedparser.parse(feed);
const latestItems = items
.filter(item => {
const pubDate = new Date(item.pubDate);
const now = new Date();
// 24์๊ฐ ์ด๋ด์ ๊ธ๋ง ํํฐ๋ง
return (now - pubDate) < 24 * 60 * 60 * 1000;
})
.map(item => ({
title: item.title,
link: item.link,
pubDate: item.pubDate,
description: item.description
}));
// ์๋ก์ด ๊ธ ๋ฐ๊ฒฌ์ ์ฒ๋ฆฌ
if (latestItems.length > 0) {
updateBlogPost(latestItems);
}
}
} catch (error) {
console.error('RSS ํผ๋ ๋ชจ๋ํฐ๋ง ์ค ์ค๋ฅ:', error);
}
}
// 6์๊ฐ๋ง๋ค ์คํ
setInterval(monitorRSSFeeds, 6 * 60 * 60 * 1000);
2. AI ๋ด์ค ํฌ๋กค๋ฌ
์ฃผ์ AI ๋ด์ค ์ฌ์ดํธ์ ์ต์ ์ ๋ณด๋ฅผ ์์งํ๋ ํฌ๋กค๋ฌ์ ๋๋ค.
const axios = require('axios');
const cheerio = require('cheerio');
async function crawlAINews() {
const sites = [
{
url: 'https://venturebeat.com/category/ai/',
selector: 'article.Article'
},
{
url: 'https://www.artificialintelligence-news.com/',
selector: '.post-title'
}
];
for (const site of sites) {
try {
const response = await axios.get(site.url);
const $ = cheerio.load(response.data);
const articles = [];
$(site.selector).each((i, elem) => {
const title = $(elem).find('h2').text().trim();
const link = $(elem).find('a').attr('href');
if (title && link) {
articles.push({ title, link });
}
});
// ์๋ก์ด ๊ธฐ์ฌ ๋ฐ๊ฒฌ์ ์ฒ๋ฆฌ
if (articles.length > 0) {
updateBlogPost(articles);
}
} catch (error) {
console.error(`ํฌ๋กค๋ง ์ค ์ค๋ฅ (${site.url}):`, error);
}
}
}
// 3์๊ฐ๋ง๋ค ์คํ
setInterval(crawlAINews, 3 * 60 * 60 * 1000);
3. API ์ํ ๋ชจ๋ํฐ๋ง
์ฃผ์ AI API์ ์ํ์ ์ ๋ฐ์ดํธ๋ฅผ ๋ชจ๋ํฐ๋งํฉ๋๋ค.
const { Configuration, OpenAIApi } = require('openai');
const { GoogleAuth } = require('google-auth-library');
async function checkAPIStatus() {
const apis = [
{
name: 'OpenAI',
checkFunction: async () => {
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY
});
const openai = new OpenAIApi(configuration);
const response = await openai.listModels();
return response.data;
}
},
{
name: 'Google AI',
checkFunction: async () => {
const auth = new GoogleAuth({
keyFilename: 'path/to/service-account.json'
});
const client = await auth.getClient();
const response = await client.request({
url: 'https://api.googleapis.com/v1/models'
});
return response.data;
}
}
];
for (const api of apis) {
try {
const status = await api.checkFunction();
updateBlogPost({
apiName: api.name,
status: 'active',
lastChecked: new Date(),
details: status
});
} catch (error) {
console.error(`API ์ฒดํฌ ์ค ์ค๋ฅ (${api.name}):`, error);
}
}
}
// 1์๊ฐ๋ง๋ค ์คํ
setInterval(checkAPIStatus, 60 * 60 * 1000);
4. ๋ฐ์ดํฐ ๊ฒ์ฆ ์์คํ
์์ง๋ ์ ๋ณด์ ์ ๋ขฐ์ฑ์ ๊ฒ์ฆํ๋ ์์คํ ์ ๋๋ค.
class DataValidator {
constructor() {
this.trustedSources = new Set([
'openai.com',
'google.com',
'arxiv.org',
'microsoft.com',
'deepmind.com'
]);
}
validateSource(url) {
try {
const domain = new URL(url).hostname;
return this.trustedSources.has(domain);
} catch {
return false;
}
}
validateDate(pubDate) {
const date = new Date(pubDate);
const now = new Date();
// ์ผ์ฃผ์ผ ์ด๋ด์ ๋ฐ์ดํฐ๋ง ์ ํจ
return (now - date) < 7 * 24 * 60 * 60 * 1000;
}
async validateContent(content) {
// ํค์๋ ๊ธฐ๋ฐ ๊ฒ์ฆ
const aiKeywords = ['artificial intelligence', 'machine learning', 'deep learning', 'neural network'];
return aiKeywords.some(keyword =>
content.toLowerCase().includes(keyword)
);
}
async validate(data) {
return {
isValidSource: this.validateSource(data.url),
isValidDate: this.validateDate(data.pubDate),
isValidContent: await this.validateContent(data.content)
};
}
}
const validator = new DataValidator();
// ์ฌ์ฉ ์์
async function validateAndUpdate(data) {
const validation = await validator.validate(data);
if (validation.isValidSource &&
validation.isValidDate &&
validation.isValidContent) {
updateBlogPost(data);
}
}

๋๊ธ
๋๊ธ ์ฐ๊ธฐ