blog-post-optimizer
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBlog Post Optimizer
博文优化工具
Comprehensive content analysis toolkit for optimizing blog posts, articles, and web content. Analyzes headlines, SEO elements, content structure, readability, and generates actionable recommendations with scores.
一款用于优化博文、文章及网页内容的综合性内容分析工具。可分析标题、SEO元素、内容结构、可读性,并生成带有评分的可执行优化建议。
Quick Start
快速开始
python
from scripts.blog_post_optimizer import BlogPostOptimizerpython
from scripts.blog_post_optimizer import BlogPostOptimizerInitialize optimizer
Initialize optimizer
optimizer = BlogPostOptimizer()
optimizer = BlogPostOptimizer()
Analyze a blog post
Analyze a blog post
with open('blog_post.md', 'r') as f:
content = f.read()
with open('blog_post.md', 'r') as f:
content = f.read()
Full analysis
Full analysis
results = optimizer.analyze_full(
content=content,
headline="10 Ways to Boost Your Productivity",
keywords=["productivity", "time management", "efficiency"]
)
results = optimizer.analyze_full(
content=content,
headline="10 Ways to Boost Your Productivity",
keywords=["productivity", "time management", "efficiency"]
)
View scores
View scores
print(f"Overall Score: {results['overall_score']}/100")
print(f"Headline Score: {results['headline']['score']}/100")
print(f"SEO Score: {results['seo']['score']}/100")
print(f"Readability Grade: {results['readability']['grade_level']}")
print(f"Overall Score: {results['overall_score']}/100")
print(f"Headline Score: {results['headline']['score']}/100")
print(f"SEO Score: {results['seo']['score']}/100")
print(f"Readability Grade: {results['readability']['grade_level']}")
Export HTML report
Export HTML report
optimizer.export_html_report(results, 'report.html')
undefinedoptimizer.export_html_report(results, 'report.html')
undefinedFeatures
功能特性
1. Headline Analysis
1. 标题分析
- Power Words Detection - Identifies emotional trigger words
- Character Count - Optimal range 50-60 characters
- Emotional Impact - Measures headline engagement potential
- A/B Suggestions - Generate alternative headlines
- Power Words Detection - 识别情感触发词
- Character Count - 最优范围为50-60字符
- Emotional Impact - 评估标题的潜在吸引力
- A/B Suggestions - 生成备选标题
2. SEO Optimization
2. SEO优化
- Keyword Density - Target 1-2% for primary keyword
- Keyword Prominence - Check placement in first 100 words
- Meta Description - Auto-generate 150-160 characters
- Title Tag - Optimize for 50-60 characters
- URL Slug - Generate SEO-friendly slugs
- Keyword Density - 主关键词目标密度为1-2%
- Keyword Prominence - 检查关键词是否出现在前100词中
- Meta Description - 自动生成150-160字符的描述
- Title Tag - 优化至50-60字符
- URL Slug - 生成SEO友好的URL别名
3. Content Structure
3. 内容结构
- Heading Hierarchy - Validate H1/H2/H3 structure
- Paragraph Length - Ideal 3-5 sentences
- List Usage - Detect numbered and bulleted lists
- Image Placement - Check for visual elements
- Subheading Distribution - Ensure consistent spacing
- Heading Hierarchy - 验证H1/H2/H3层级结构
- Paragraph Length - 理想长度为3-5句
- List Usage - 检测编号列表和项目符号列表
- Image Placement - 检查视觉元素的位置
- Subheading Distribution - 确保副标题分布均匀
4. Readability Analysis
4. 可读性分析
- Flesch-Kincaid Grade - Target grade 8-10
- Reading Ease - 60-70 is ideal
- Sentence Complexity - Average words per sentence
- Passive Voice - Percentage (aim for <10%)
- Flesch-Kincaid Grade - 目标等级为8-10级
- Reading Ease - 理想分数为60-70
- Sentence Complexity - 平均句长(单词数)
- Passive Voice - 被动语态占比(目标<10%)
5. Content Statistics
5. 内容统计
- Word Count - Article length tracking
- Reading Time - Estimated at 265 words/minute
- Character Count - Total characters
- Average Sentence Length - Words per sentence
- Word Count - 文章字数追踪
- Reading Time - 按每分钟265词估算阅读时间
- Character Count - 总字符数
- Average Sentence Length - 平均句长(单词数)
6. Meta Tag Generation
6. 元标签生成
- Open Graph - Social media preview tags
- Twitter Cards - Twitter-specific meta tags
- Schema.org - Article structured data (JSON-LD)
- Open Graph - 社交媒体预览标签
- Twitter Cards - Twitter专属元标签
- Schema.org - 文章结构化数据(JSON-LD)
API Reference
API参考
BlogPostOptimizer
BlogPostOptimizer
python
optimizer = BlogPostOptimizer()python
optimizer = BlogPostOptimizer()analyze_headline(headline: str) -> Dict
analyze_headline(headline: str) -> Dict
Analyze headline effectiveness.
Returns:
python
{
'score': 75, # 0-100
'character_count': 52,
'power_words': ['boost', 'proven'],
'emotional_impact': 68,
'suggestions': [
"10 Proven Ways to Boost Your Productivity Today",
"Boost Your Productivity: 10 Essential Strategies"
]
}分析标题的有效性。
返回值:
python
{
'score': 75, # 0-100
'character_count': 52,
'power_words': ['boost', 'proven'],
'emotional_impact': 68,
'suggestions': [
"10 Proven Ways to Boost Your Productivity Today",
"Boost Your Productivity: 10 Essential Strategies"
]
}analyze_seo(content: str, keywords: List[str]) -> Dict
analyze_seo(content: str, keywords: List[str]) -> Dict
Analyze SEO elements.
Returns:
python
{
'score': 80,
'keyword_density': {'productivity': 1.8, 'time management': 0.9},
'keyword_prominence': True, # In first 100 words
'meta_description': 'Discover 10 proven ways to boost productivity...',
'title_tag': '10 Ways to Boost Productivity | Your Site',
'url_slug': 'boost-productivity-10-ways'
}分析SEO元素。
返回值:
python
{
'score': 80,
'keyword_density': {'productivity': 1.8, 'time management': 0.9},
'keyword_prominence': True, # In first 100 words
'meta_description': 'Discover 10 proven ways to boost productivity...',
'title_tag': '10 Ways to Boost Productivity | Your Site',
'url_slug': 'boost-productivity-10-ways'
}analyze_structure(content: str) -> Dict
analyze_structure(content: str) -> Dict
Analyze content structure.
Returns:
python
{
'score': 85,
'h1_count': 1,
'h2_count': 10,
'avg_paragraph_length': 4.2, # Sentences
'list_count': 3,
'warnings': ['Paragraph on line 45 is too long (8 sentences)']
}分析内容结构。
返回值:
python
{
'score': 85,
'h1_count': 1,
'h2_count': 10,
'avg_paragraph_length': 4.2, # Sentences
'list_count': 3,
'warnings': ['Paragraph on line 45 is too long (8 sentences)']
}analyze_readability(content: str) -> Dict
analyze_readability(content: str) -> Dict
Calculate readability scores.
Returns:
python
{
'flesch_kincaid_grade': 8.5,
'reading_ease': 65.2,
'avg_sentence_length': 15.3,
'passive_voice_pct': 8.5,
'complexity_score': 72
}计算可读性分数。
返回值:
python
{
'flesch_kincaid_grade': 8.5,
'reading_ease': 65.2,
'avg_sentence_length': 15.3,
'passive_voice_pct': 8.5,
'complexity_score': 72
}calculate_content_stats(content: str) -> Dict
calculate_content_stats(content: str) -> Dict
Calculate basic content statistics.
Returns:
python
{
'word_count': 1250,
'reading_time_minutes': 5,
'character_count': 7890,
'sentence_count': 85,
'paragraph_count': 28
}计算基础内容统计数据。
返回值:
python
{
'word_count': 1250,
'reading_time_minutes': 5,
'character_count': 7890,
'sentence_count': 85,
'paragraph_count': 28
}generate_meta_tags(title: str, description: str, keywords: List[str]) -> Dict
generate_meta_tags(title: str, description: str, keywords: List[str]) -> Dict
Generate social media and SEO meta tags.
Returns:
python
{
'open_graph': {
'og:title': '10 Ways to Boost Your Productivity',
'og:description': 'Discover proven strategies...',
'og:type': 'article'
},
'twitter_card': {
'twitter:card': 'summary_large_image',
'twitter:title': '10 Ways to Boost Your Productivity'
},
'schema_org': {
'@context': 'https://schema.org',
'@type': 'Article',
'headline': '10 Ways to Boost Your Productivity'
}
}生成社交媒体及SEO元标签。
返回值:
python
{
'open_graph': {
'og:title': '10 Ways to Boost Your Productivity',
'og:description': 'Discover proven strategies...',
'og:type': 'article'
},
'twitter_card': {
'twitter:card': 'summary_large_image',
'twitter:title': '10 Ways to Boost Your Productivity'
},
'schema_org': {
'@context': 'https://schema.org',
'@type': 'Article',
'headline': '10 Ways to Boost Your Productivity'
}
}analyze_full(content: str, headline: str, keywords: List[str]) -> Dict
analyze_full(content: str, headline: str, keywords: List[str]) -> Dict
Complete analysis combining all methods.
Returns:
python
{
'overall_score': 78,
'headline': {...},
'seo': {...},
'structure': {...},
'readability': {...},
'stats': {...},
'recommendations': [
{'priority': 'high', 'issue': '...', 'fix': '...'}
]
}整合所有分析方法的完整分析。
返回值:
python
{
'overall_score': 78,
'headline': {...},
'seo': {...},
'structure': {...},
'readability': {...},
'stats': {...},
'recommendations': [
{'priority': 'high', 'issue': '...', 'fix': '...'}
]
}export_html_report(results: Dict, output_path: str)
export_html_report(results: Dict, output_path: str)
Generate color-coded HTML report with charts and recommendations.
生成带颜色编码的HTML报告,包含图表和优化建议。
CLI Usage
CLI使用方法
Single Blog Post Analysis
单篇博文分析
bash
python scripts/blog_post_optimizer.py \
--input blog_post.md \
--headline "10 Ways to Boost Your Productivity" \
--keywords "productivity,time management,efficiency" \
--output report.html \
--format htmlbash
python scripts/blog_post_optimizer.py \
--input blog_post.md \
--headline "10 Ways to Boost Your Productivity" \
--keywords "productivity,time management,efficiency" \
--output report.html \
--format htmlQuick Analysis (JSON Output)
快速分析(JSON输出)
bash
python scripts/blog_post_optimizer.py \
--input article.txt \
--headline "Ultimate Guide to Python" \
--keywords "python,programming" \
--format jsonbash
python scripts/blog_post_optimizer.py \
--input article.txt \
--headline "Ultimate Guide to Python" \
--keywords "python,programming" \
--format jsonHeadline Analysis Only
仅标题分析
bash
python scripts/blog_post_optimizer.py \
--headline-only "10 Productivity Hacks You Need to Know"bash
python scripts/blog_post_optimizer.py \
--headline-only "10 Productivity Hacks You Need to Know"CLI Arguments
CLI参数
| Argument | Description | Default |
|---|---|---|
| Input file (txt/md/html) | - |
| Blog post headline | Extracted from content |
| Comma-separated keywords | - |
| Output file path | stdout |
| Output format (json/html) | json |
| Analyze headline only | False |
| 参数 | 描述 | 默认值 |
|---|---|---|
| 输入文件(txt/md/html格式) | - |
| 博文标题 | 从内容中提取 |
| 逗号分隔的关键词 | - |
| 输出文件路径 | 标准输出 |
| 输出格式(json/html) | json |
| 仅分析标题 | False |
Examples
示例
Example 1: Full Analysis with HTML Report
示例1:完整分析并生成HTML报告
python
optimizer = BlogPostOptimizer()
with open('article.md') as f:
content = f.read()
results = optimizer.analyze_full(
content=content,
headline="The Complete Guide to Remote Work",
keywords=["remote work", "productivity", "work from home"]
)
optimizer.export_html_report(results, 'seo_report.html')python
optimizer = BlogPostOptimizer()
with open('article.md') as f:
content = f.read()
results = optimizer.analyze_full(
content=content,
headline="The Complete Guide to Remote Work",
keywords=["remote work", "productivity", "work from home"]
)
optimizer.export_html_report(results, 'seo_report.html')Example 2: Headline Optimization
示例2:标题优化
python
optimizer = BlogPostOptimizer()
headline = "Ways to Improve Your Writing"
analysis = optimizer.analyze_headline(headline)
print(f"Score: {analysis['score']}/100")
print(f"Power words found: {', '.join(analysis['power_words'])}")
print("\nSuggestions:")
for suggestion in analysis['suggestions']:
print(f" - {suggestion}")python
optimizer = BlogPostOptimizer()
headline = "Ways to Improve Your Writing"
analysis = optimizer.analyze_headline(headline)
print(f"Score: {analysis['score']}/100")
print(f"Power words found: {', '.join(analysis['power_words'])}")
print("\nSuggestions:")
for suggestion in analysis['suggestions']:
print(f" - {suggestion}")Example 3: SEO Keyword Analysis
示例3:SEO关键词分析
python
optimizer = BlogPostOptimizer()
with open('post.md') as f:
content = f.read()
seo = optimizer.analyze_seo(
content=content,
keywords=["python", "tutorial", "beginners"]
)
for keyword, density in seo['keyword_density'].items():
print(f"{keyword}: {density:.1f}%")python
optimizer = BlogPostOptimizer()
with open('post.md') as f:
content = f.read()
seo = optimizer.analyze_seo(
content=content,
keywords=["python", "tutorial", "beginners"]
)
for keyword, density in seo['keyword_density'].items():
print(f"{keyword}: {density:.1f}%")Dependencies
依赖项
nltk>=3.8.0
textblob>=0.17.0
beautifulsoup4>=4.12.0
pandas>=2.0.0
matplotlib>=3.7.0
reportlab>=4.0.0
lxml>=4.9.0nltk>=3.8.0
textblob>=0.17.0
beautifulsoup4>=4.12.0
pandas>=2.0.0
matplotlib>=3.7.0
reportlab>=4.0.0
lxml>=4.9.0Limitations
局限性
- HTML Parsing: Complex HTML structures may affect accuracy
- Keyword Context: Doesn't account for keyword context (positive/negative)
- Language: English only for readability and power words
- Power Words: Subjective; effectiveness varies by audience
- Readability: Formulas are guides, not absolute measures
- SEO: Search engine algorithms constantly change
- Image Analysis: Cannot analyze actual image content
- External Links: Doesn't validate external link quality
- HTML解析:复杂的HTML结构可能影响分析准确性
- 关键词语境:无法识别关键词的语境(正面/负面)
- 语言支持:仅支持英文的可读性分析和情感触发词识别
- 情感触发词:主观性较强,效果因受众而异
- 可读性:公式仅作参考,并非绝对标准
- SEO:搜索引擎算法持续变化
- 图片分析:无法分析图片的实际内容
- 外部链接:无法验证外部链接的质量