// 简单的SEO检查脚本
const puppeteer = require('puppeteer');
async function checkSEO(url) {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(url);
const seoData = await page.evaluate(() => {
return {
title: document.title,
description: document.querySelector('meta[name="description"]')?.content,
h1Count: document.querySelectorAll('h1').length,
h2Count: document.querySelectorAll('h2').length,
imagesWithoutAlt: Array.from(document.querySelectorAll('img')).filter(img => !img.alt).length
};
});
console.log('SEO检查结果:', seoData);
await browser.close();
}
checkSEO('https://yoursite.com');