Blogger SEO Analyzer
Blogger SEO Analyzer
// Example using Google Apps Script (free option)
function analyzeBloggerSEO(url) {
const response = UrlFetchApp.fetch(url);
const html = response.getContentText();
// Extract keywords
const words = html.toLowerCase().match(/\b\w+\b/g);
const wordCount = {};
words.forEach(word => {
wordCount[word] = (wordCount[word] || 0) + 1;
});
// Check meta tags
const hasMetaDesc = html.includes('
{
if (!STOP_WORDS.includes(word)) { // Exclude common words
wordCount[word] = (wordCount[word] || 0) + 1;
}
});
return Object.entries(wordCount)
.sort((a, b) => b[1] - a[1])
.map(([word, count]) => ({
word,
count,
density: ((count / totalWords) * 100).toFixed(2) + '%'
}));
}function analyzeMetaTags(html) {
const $ = cheerio.load(html);
const results = {
hasTitle: $('title').text().length > 0,
hasMetaDescription: $('meta[name="description"]').attr('content') !== undefined,
hasCanonical: $('link[rel="canonical"]').attr('href') !== undefined,
imageAlts: $('img:not([alt])').length
};
return results;
}async function checkBrokenLinks(html, baseUrl) {
const $ = cheerio.load(html);
const links = $('a').map((i, el) => $(el).attr('href')).get();
const broken = [];
await Promise.all(links.map(async link => {
if (!link.startsWith('http')) link = new URL(link, baseUrl).href;
try {
const res = await fetch(link, { method: 'HEAD' });
if (res.status >= 400) broken.push({ url: link, status: res.status });
} catch (e) {
broken.push({ url: link, status: 'Failed to fetch' });
}
}));
return broken;
}// Using Google PageSpeed Insights API
async function getPageSpeed(url) {
const apiKey = 'YOUR_GOOGLE_API_KEY';
const apiUrl = `https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=${encodeURIComponent(url)}&key=${apiKey}`;
const response = await fetch(apiUrl);
const data = await response.json();
return {
performanceScore: data.lighthouseResult.categories.performance.score * 100,
loadingTime: data.lighthouseResult.audits['speed-index'].displayValue,
recommendations: data.lighthouseResult.audits['diagnostics'].details.items
};
}
Comments
Post a Comment