Cluster keywords based on common SERP URLs. This script processes batch exports from ValueSERP and groups keywords that share common ranking URLs.
- Process multiple CSV files from ValueSERP batch exports
- Cluster keywords based on configurable number of common URLs
- Automatic cluster naming based on shortest keyword
- Progress bars for long-running operations
- Export results to CSV
pip install -r requirements.txt- Export SERP data from ValueSERP in CSV format
- Place all CSV files in a folder (default:
valueserp_exportsin the script directory) - Update the configuration variables if needed:
FOLDER_LOCATION: Path to your CSV filesCOMMON_URLS: Minimum number of common URLs to form a cluster (default: 4)EXPORT_CSV_FILE_PATH: Output file path
- Run the script:
python serp_clustering_at_scale.py| Variable | Default | Description |
|---|---|---|
CONSOLIDATE_QUERIES |
True |
Consolidate overlapping clusters |
COMMON_URLS |
4 |
Minimum common URLs to match keywords |
FOLDER_LOCATION |
./valueserp_exports |
Folder containing ValueSERP exports |
FILE_PREFIX |
/Batch_Results_*.csv |
File pattern to match |
The script generates a CSV file with the following columns:
serp_cluster: The cluster name (shortest keyword in cluster)query: The keyword#_kws_in_cluster: Number of keywords in the cluster#_common_urls: Number of common URLscommon_urls: List of common URLs
Lee Foot - eCommerce SEO Consultant