An automated system for generating and publishing AI-focused blog posts using Python, OpenAI's GPT, and WordPress integration. This system automatically fetches trending AI topics, generates engaging content, and publishes it to your WordPress site.
- 🤖 Automated content generation using OpenAI's GPT
- 📊 Smart topic selection with keyword ranking system
- 🔒 Secure credential management
- 🌐 WordPress REST API integration
- 📝 HTML-formatted blog posts
- 🎯 Small business and entrepreneurship focus
- Python 3.10+
- WordPress site with REST API enabled
- OpenAI API key
- WordPress application password
- Clone the repository:
git clone [your-repo-url]
cd trendingAIblogs
- Create a virtual environment:
# Windows
py -m venv env
# Unix/MacOS
python3 -m venv env
- Activate the virtual environment:
# Windows
.\env\Scripts\activate
# Unix/MacOS
source env/bin/activate
- Install dependencies:
pip install -r requirements.txt
- Run the setup script to configure credentials:
python setup.py
The easiest way to run the blog generator is using the provided batch script:
- Double-click
run_blog.bat
(Windows)- This will automatically activate the virtual environment
- Run the blog generator
- Show you the output
- Keep the window open until you press a key
Alternatively, you can run manually:
python daily_ai_blog.py
- Create a
.env
file with your credentials:
WORDPRESS_URL=https://your-site.com/
WORDPRESS_USERNAME=your-username
OPENAI_API_KEY=your-api-key
Run the script:
python daily_ai_blog.py
The script will:
- Fetch trending AI topics
- Rank them based on relevance
- Generate a blog post
- Save it for review
- Publish to WordPress after approval
The system uses a sophisticated ranking algorithm that:
- Awards points for relevant keywords (AI tools, developments, innovations)
- Subtracts points for unwanted topics (financial, stock market)
- Ranks all topics by score for optimal selection
The content generation is optimized for:
- Small business audience
- Practical AI applications
- Cost-effective solutions
- Clear calls-to-action
- Professional yet approachable tone
The system uses carefully chosen search terms and ranking keywords to find relevant AI news. Here's how to customize them for your needs:
In get_trending_ai_topics()
, modify the search queries based on your focus:
search_queries = [
'new AI tool release',
'artificial intelligence development',
'AI research breakthrough',
'machine learning innovation',
'AI technology advancement'
]
- These queries are designed to find news about new tools and developments rather than financial news
- Add queries relevant to your industry or specific AI interests
- Keep queries specific enough to get relevant results but broad enough to get sufficient content
In rank_and_filter_topics()
, customize the keywords that determine article relevance:
relevant_keywords = [
'tool', 'launch', 'release', # New product announcements
'research', 'breakthrough', # Technical developments
'innovation', 'platform', # Industry advancement
'open source', 'model', # AI model releases
'small business' # Target audience focus
]
exclude_keywords = [
'stock', 'market', 'invest', # Financial news
'price', 'revenue', 'earnings' # Market performance
]
- Each relevant keyword match adds +1 to the topic's score
- Each exclude keyword match subtracts -0.5 from the score
- Adjust these weights in the code to make the filtering more or less strict
The blog generation prompt in generate_blog_post()
is crucial for producing content that matches your goals:
prompt = (
"Write an engaging and informative blog post that:"
"1. Starts with a compelling title\n"
"2. Relates to practical business benefits\n"
"3. Breaks down complex AI concepts\n"
"4. Includes real-world examples\n"
"5. Highlights cost-effective solutions\n"
)
- Audience Focus: Currently targets small business owners - modify for your target audience
- Content Structure: Adjust the HTML formatting for your WordPress theme
- Tone and Style: Change the professional yet approachable tone as needed
- Call to Action: Customize the ending to match your business goals
- Ethical Guidelines: Currently includes Sharia compliance - modify or remove based on your values
For a technical AI blog:
relevant_keywords = ['algorithm', 'architecture', 'framework', 'implementation']
prompt = "Write a technical deep-dive into the AI technology..."
For an AI education blog:
relevant_keywords = ['learning', 'tutorial', 'guide', 'introduction']
prompt = "Write a beginner-friendly explanation of the AI concept..."
Remember to test your customizations with a few sample runs to ensure the content meets your expectations.
Contributions are welcome! Please feel free to submit a Pull Request.