Tired of playing keyword guessing games when planning landing pages? I’ve got the perfect time-saving trick up my digital sleeve! It involves a Python-powered spreadsheet that streamlines SERP overlap analysis, revealing which keywords deserve their own spotlight and which can happily share the stage.

import pandas as pd
from googlesearch import search
from urllib.parse import urlparse

# Load the CSV file with keywords
keywords_df = pd.read_csv("Keywords.csv")

# Create a dictionary to store SERP results for each keyword
serps_dict = {}

# Function to get SERP results for a keyword
def get_serps(keyword):
serps = list(search(keyword, num=10, stop=10))
return [urlparse(url).netloc for url in serps]

# Iterate through the keywords and get SERP results
for keyword in keywords_df["Keyword"]:
serps_dict[keyword] = get_serps(keyword)

# Create a matrix to store the overlap percentages
matrix = pd.DataFrame(index=keywords_df["Keyword"], columns=keywords_df["Keyword"])

# Function to calculate the overlap percentage between two keywords
def calculate_overlap(keyword1, keyword2):
serps1 = set(serps_dict[keyword1])
serps2 = set(serps_dict[keyword2])
overlap_count = len(serps1.intersection(serps2))
if len(serps1) == 0 or len(serps2) == 0:
return 0 # Handle division by zero
overlap_percentage = (overlap_count / max(len(serps1), len(serps2))) * 100
return overlap_percentage

# Fill in the matrix with overlap percentages
for i in range(len(keywords_df)):
for j in range(i, len(keywords_df)):
keyword1 = keywords_df.iloc[i]["Keyword"]
keyword2 = keywords_df.iloc[j]["Keyword"]
overlap_percentage = calculate_overlap(keyword1, keyword2)
matrix.at[keyword1, keyword2] = overlap_percentage
matrix.at[keyword2, keyword1] = overlap_percentage

# Save the matrix as a CSV file
matrix.to_csv("serp_overlap_matrix.csv")

Here’s how it works:

  1. Import the Essential Ingredients: Begin by loading the necessary Python libraries, like pandas for data manipulation and requests for fetching SERP results.
  2. Gather Your Keywords: Load a CSV file containing your target keywords, ready for thorough analysis.
  3. Create a Keyword SERP Dictionary: Construct a dictionary to store the SERP results for each keyword, acting as a treasure trove of insights.
  4. Define Your SERP Retriever: Craft a function that fetches the SERP results for a given keyword, acting as your trusty data-gathering sidekick.
  5. Iterate and Populate: Loop through your keywords, calling the SERP retriever function for each one, and neatly storing the results in the dictionary.
  6. Construct the Overlap Matrix: Build an empty matrix, ready to house the calculated overlap percentages between all keyword pairs.
  7. Calculate Overlap Percentages: Define a function that meticulously compares two sets of SERP results, determining the percentage of overlap between them.
  8. Fill the Matrix with Insights: Populate the matrix with overlap percentages for each keyword duo, unveiling their content relationships.
  9. Save Your Findings: Export the overlap matrix as a CSV file, preserving your knowledge for future reference and strategic planning.

The Benefits of This Technique:

Curious to Unleash the Power of Python for SERP Analysis? Let’s chat! I’m eager to share more details and help you streamline your keyword research and landing page decisions.

Leave a Reply

Your email address will not be published. Required fields are marked *