SEO Fuzzy Match is a Python script that facilitates URL redirection during website migrations. It compares content from an old and updated version of a website, using Excel/CSV data from website crawlers like Screaming Frog SEO Spider, to automatically suggest which URLs in the new site correspond to old ones.
This tool is ideal for those tricky situations where URLs and contents have changed between website versions. By comparing the content of the old and new resources, SEO Fuzzy Match can help you identify the best matches and create a redirection plan.
- Uses cosine similarity to identify the most similar content between old and new URLs.
- Supports various file formats for input data (CSV and Excel).
- Allows the selection of specific columns for URL and content comparison.
- Exports the matched results into a CSV file, ready for use in URL redirection.
This script requires the following Python libraries:
pandasfor data handlingscikit-learnfor TF-IDF vectorization and cosine similarity calculationtkinter(built-in) for file selection dialogswarnings(built-in) for suppressing openpyxl warningsre(built-in) for identifying with regular expressions the warning to suppress
Install the required packages via pip:
pip install pandas scikit-learn- Run the script:
python seo-fuzzy-match.py
- Select the old and new website data files when prompted. Each file should contain a list of URLs and their text features (e.g., page titles, meta descriptions), typically exported from a website crawler.
- Select the column indices for the source URLs in the old data and the target URLs in the new data.
- Select the column indices for text features to compare. You can select multiple columns by separating them with commas (e.g., 1,2,3).
- (Optional) Select a source URL text file to limit the URLs considered in the old website. The file should contain one URL per line.
The script will output a CSV file (url_mapping.csv) with the old URLs, new URLs, and a similarity score, indicating how strong the match is between the old and new content.
When selecting columns for text features, consider the following:
- The columns you select should contain unique data that can help the tool identify specific resources. Good candidates include page titles, meta descriptions, product SKUs, or other distinctive content.
- Prioritize data that has not changed between the old and new websites.
- Even if a column’s content isn’t fully unique, it can still be useful in combination with other columns to identify resources effectively.
- Updated handling of warnings from
openpyxlwhen reading Excel files without a default style. - Added comments to the most important steps.
- Initial release with core functionality:
- Compares old and new website content using cosine similarity.
- Reads data from Excel and CSV files, supporting file selection via a GUI dialog.
This project is licensed under the MIT License.