discordbot/test-trends.js
ale 17a70e8882
google trends
Signed-off-by: ale <ale@manalejandro.com>
2025-06-08 06:33:54 +02:00

32 lines
1.1 KiB
JavaScript

// Test Google Trends API
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const googleTrends = require('google-trends-api');
async function testTrends() {
try {
console.log('Testing Google Trends API...');
const query = { geo: 'ES' };
const results = await googleTrends.realTimeTrends(query);
const trendsData = JSON.parse(results);
console.log('✅ API working!');
console.log('📈 Found', trendsData.storySummaries.trendingStories.length, 'trending stories');
// Show first trend
if (trendsData.storySummaries.trendingStories.length > 0) {
const firstTrend = trendsData.storySummaries.trendingStories[0];
console.log('🔥 Top trend:', firstTrend.title);
if (firstTrend.articles && firstTrend.articles.length > 0) {
console.log('📰 First article:', firstTrend.articles[0].articleTitle);
}
}
} catch (error) {
console.error('❌ Error:', error.message);
}
}
testTrends();