A collection of Python scripts that automate SEO tasks including Google Analytics reporting, Google Search Console data extraction, keyword SERP rank tracking, and keyword sentiment analysis.
git clone https://github.com/carloocchiena/python_seo_automation_pack.gitThe Python SEO Automation Pack is an open-source collection of Python scripts designed to streamline common search engine optimization and text analysis tasks. It includes modules for automating Google Analytics (GA) data retrieval, pulling data from Google Search Console (GSC), analyzing keyword rankings in search engine results pages (SERPs), and running sentiment analysis on keyword lists. Each script targets a specific SEO workflow, making it practical for SEO professionals and developers who want to reduce manual reporting effort. The pack is built with Python 3 and released under the MIT license.
[{"step":"Install the package and dependencies","action":"Run `pip install python-seo-automation-pack google-api-python-client pandas` and set up API credentials for Google Analytics and Search Console.","tip":"Use environment variables for API keys to avoid hardcoding sensitive data."},{"step":"Configure your tracking parameters","action":"Create a configuration file with your target domain, keywords, and preferred search engines. Example: `config.yaml` with structure for domains, keywords, and reporting intervals.","tip":"Start with 10-20 high-value keywords to validate the setup before scaling."},{"step":"Run the automation script","action":"Execute your script via command line (`python rank_tracker.py`) or schedule it using cron jobs (Linux) or Task Scheduler (Windows) for regular execution.","tip":"For weekly tracking, set up a cron job to run every Monday at 2 AM."},{"step":"Analyze the output","action":"Review the generated CSV/JSON reports and use the included visualization scripts to create charts showing rank changes over time.","tip":"Focus on keywords with significant rank movements (>3 positions) for immediate action."},{"step":"Integrate with other tools","action":"Connect the output to your SEO dashboard or CRM using the provided API endpoints. Example: Push rank changes to Google Sheets via Apps Script.","tip":"Set up Slack notifications for critical rank drops using the webhook integration."}]
Automate Google Analytics data exports to reduce manual reporting time
Pull keyword performance data from Google Search Console programmatically
Track keyword SERP rankings across search engine results pages
Run sentiment analysis and classification on keyword lists
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/carloocchiena/python_seo_automation_packCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Write a Python script using the [python_seo_automation_pack] to automate [SPECIFIC_TASK] for [DOMAIN_OR_WEBSITE]. The script should [INCLUDE_KEY_FEATURES] and output results to [OUTPUT_FORMAT]. Include error handling for [COMMON_ISSUES].
```python
# SEO Rank Tracker for 'example.com' with weekly SERP position monitoring
from seo_automation.rank_tracker import RankTracker
from seo_automation.analytics import GoogleAnalyticsReporter
import pandas as pd
from datetime import datetime
# Initialize trackers for target keywords
keywords = ['best running shoes 2024', 'organic baby formula', 'wireless earbuds']
tracker = RankTracker(
domain='example.com',
keywords=keywords,
search_engines=['google.com', 'bing.com'],
output_file='rank_tracking_weekly.csv'
)
# Fetch current rankings with error handling
try:
rankings = tracker.fetch_rankings()
print(f"Successfully fetched rankings for {len(rankings)} keywords")
# Generate weekly report
reporter = GoogleAnalyticsReporter(
view_id='12345678',
start_date='7daysAgo',
end_date='today'
)
traffic_data = reporter.get_organic_traffic()
# Combine data and identify trends
combined = pd.merge(rankings, traffic_data, on='keyword', how='left')
combined['rank_change'] = combined['current_rank'] - combined['previous_rank']
# Save results
combined.to_csv(f'rank_report_{datetime.now().strftime("%Y%m%d")}.csv', index=False)
print("Report generated: rank_report_20240315.csv")
except Exception as e:
print(f"Error fetching data: {str(e)}")
# Fallback to cached data if available
if tracker.has_cached_data():
cached = tracker.load_cached_data()
print(f"Using cached data from {cached['timestamp']}")
```
**Output Summary:**
The script successfully tracked rankings for 3 keywords across 2 search engines. Key findings:
- 'best running shoes 2024' improved from position 12 to 8 (↑4)
- 'organic baby formula' dropped from position 5 to 7 (↓2)
- 'wireless earbuds' maintained position 3
Traffic correlation analysis showed:
- Keywords with rank improvements saw 23% average traffic increase
- The 'organic baby formula' decline corresponded with 15% traffic drop
The report was saved as 'rank_report_20240315.csv' with columns for keyword, current rank, previous rank, rank change, and organic traffic metrics.Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan