How To Perform Keyword and Landing Page Analysis Using Python

How To Perform Keyword and Landing Page Analysis Using Python

In the world of digital marketing, understanding the importance of keywords and optimizing landing pages is crucial to drive organic traffic and enhance website performance. Performing keyword and landing page analysis using Python can provide valuable insights into your website’s SEO strategy, helping you make data-driven decisions. In this article, we will explore the step-by-step process of analyzing keyword and landing pages using Python.

How To Perform Keyword and Landing Page Analysis Using Python

Using this Python tool we can check the keywords is present on the respective landing page or not, so that we can take further action. 

Step 1:

Create a folder on desktop –

Create an xlsx file same as shown in the screenshot –

Rename it – keywords_and_urls

Open the file –

Add those same headings.

From your targeted keyword list fill those areas, add keywords and their landing page. Same as screenshot.

Step 2:

Open anaconda prompt –

Using cd code open the folder.

Run 3 pip code –

pip install requests

pip install pandas

pip install openpyxl

Step 3:

import requests

import re

import pandas as pd

def check_keyword_on_landing_page(keyword, landing_page_url):


        # Fetch the content of the landing page

        response = requests.get(landing_page_url)

        response.raise_for_status()  # Raise an exception for 4xx and 5xx status codes

        landing_page_content = response.text

        # Check the presence of the keyword on the landing page

        pattern = re.compile(r’\b{}\b’.format(re.escape(keyword)), re.IGNORECASE)

        keyword_presence = bool(

        return keyword_presence

    except requests.exceptions.RequestException as e:

        print(“Error fetching the landing page:”, e)

        return None

if __name__ == “__main__”:

    # Read the data from the Excel file

    excel_file_path = “keywords_and_urls.xlsx”  # Replace with the actual path to your Excel file

    df = pd.read_excel(excel_file_path, engine=’openpyxl’)

    # Create a new column ‘Keyword Presence’ to store the result for each row

    df[‘Keyword Presence’] = None

    # Iterate through each row and check the presence of the keyword on the corresponding landing page

    for i, row in df.iterrows():

        keyword = row[‘Keywords’]

        landing_page_url = row[‘Landing Page URLs’]

        print(f”Analyzing landing page: {landing_page_url}”)

        keyword_presence = check_keyword_on_landing_page(keyword, landing_page_url)

        # Update the ‘Keyword Presence’ column with the result[i, ‘Keyword Presence’] = keyword_presence

    # Export the updated DataFrame to a new Excel file

    output_file_path = “keyword_presence_results.xlsx”  # Replace with the desired path for the output file

    df.to_excel(output_file_path, index=False, engine=’openpyxl’)

    print(f”Results exported to {output_file_path}.”)

Save the code as python, and rename it as


Run the code on anaconda prompt –

The code successfully worked.

Check the folder for a file –

Open it –

Those 2 keywords are not present on that landing page.


  • Need to implement the keyword on that landing page.
  • Need to add relevant content on that landing page.
  • Need to optimize the page using SEO tool to check the SEO score.

Performing keyword and landing page analysis using Python can significantly improve your website’s SEO strategy and organic traffic. By understanding the relevance and search volume of keywords, you can optimize your landing pages for higher rankings on search engine results. Python’s automation capabilities make it an invaluable tool for continuous analysis and data-driven decision-making.

Leave a Reply

Your email address will not be published.