Skip to content

Develop a Keyword Research Tool With C# & Python

How to Develop a Keyword Research Tool? In this post, I will answer and show you step by step how easily you can do that with the Help of Google Suggestions Free API.

develop a keyword tool

You can use keyword tools to:

  • Find Content Ideas
  • Explore Keywords To Rank On Search Engines.
  • Or, best of all, sell it as a Subscription SaaS Product with some other features.

All that sounds great.

Last Week, I reverse-engineered 2 Big Keyword Research Tools that are paid, and I found out how they work and how you can build the same on your own.

Even if you are not so experienced in programming, you can still easily follow up with this tutorial and Develop your own Keyword Research Tool with Python or C#.

So, what are those two websites?

How does “Answerthepublic.com” Work?

Answerthepublic.com is a website that allows users to type in a keyword or phrase and receive a list of related questions, prepositions, and long tail keywords that people have searched for on Google.

This can be useful for content creators who are looking for ideas for new articles, videos, or blog posts.

But, when you take a look at the pricing. You want to stay away from it! Don’t you?!

How does “Keywordtool.io” Works?

Keywordtool.io is a keyword research and analysis tool that helps users find and analyze the best keywords for their website or online business.

Both tools help you generate keyword ideas and suggestions.

But not everyone can use them because of the heavy pricing we mentioned above.

So, if you want Your Own FREE Keyword research SEO tool, follow along, and letโ€™s make it happen!

Hereโ€™s what we will cover:

  • How Most Keyword Research / Keyword Idea Tools work
  • How To Read Google autosuggestions programmatically?
  • Develop a Keyword Research Tool in Python
  • Develop a Keyword Research Tool in C#

Let’s get started.

How do Keyword Research Tools Work?

Well, it depends on the scope and functionality of the Tools youโ€™re making, the complexity, and the SEO metrics you want your Tool to Provide.

In our case, we are providing “Google “Search” and QuestionSuggestions.

Letโ€™s see how they are getting the results,

How KeywordTool.io is Getting Results for Keyword suggestions.

Letโ€™s open Google and type the same query we type into KeywordTool.io

Type โ€œPython Tutorialโ€ press space, and type the letter โ€œfโ€ you will see Google suggests keywords, ideas, and search queries!

Thatโ€™s how it works.

How is AnswerthePublic.com getting Results for Question suggestions?

Let me show you how to find Question Suggestions.

Add โ€œhowโ€ before the โ€œpython tutorialโ€ keyword in Google Search, and see what google suggests! Yes, Question Keywords! This is how tools like Answerthepublic, H-supertools, and others work.

Now as we know, How the whole process works.

Letโ€™s see how to implement it from our code and Automate the Process. To save you Time and Money.

How To Read Google autosuggestions programmatically?

Before we move on, I highly recommend you watch this short video to see the Process Visually to strengthen your concept. It is not obligatory. You can skip and continue reading!

Video Source: My YouTube Channel

Now it is time to read and automate this process in our code!

We have two approaches:

  1. Using Web Automation and Scraping
  2. Using Google Search Free API Call

I chose the second approach simply because with web automation, the operation will be slower, and you may get Re-captcha to solve, and things will be more complicated.

API Call for Google Keyword Suggestions:

If you open your browser and paste this URL, you will call the Google Suggestions API. Try it!

http://google.com/complete/search?output=toolbar&gl=COUNTRY&q=Your_QUERY

You can change the country and the query to get different Google suggestions in XML format using this call, as shown below:

That’s it! We will call this URL from within the code and read the XML output!

To help more, I developed this tool in both C# .NET and Python.

Let’s discuss both scripts a bit.

Keyword Research Tool in Python

  1. First, we import requests (Used To Call API) and xml.etree.ElementTree (User To Read XML)
  2. Define a Class named QuestionsExplorer, and a method inside, GetQuestions, and it takes some arguments questionType, userInput, and countryCode to collect the Keywords and return them.
  3. Build the search URL based on user input. and call the API
  4. Read the API response results.
  5. Loop Through the XML results. And append them to the QuestionResults Array.

Keyword Research Tool in Python (Source code)

#start
import requests
import xml.etree.ElementTree as ET
# Define Class
class QuestionsExplorer:
    def GetQuestions(self, questionType, userInput, countryCode):
        questionResults = []
        # Build Google Search Query
        searchQuery = questionType + " " + userInput + " "
        # API Call
        googleSearchUrl = "http://google.com/complete/search?output=toolbar&gl=" + \
            countryCode + "&q=" + searchQuery
        # Call The URL and Read Data
        result = requests.get(googleSearchUrl)
        tree = ET.ElementTree(ET.fromstring(result.content))
        root = tree.getroot()
        for suggestion in root.findall('CompleteSuggestion'):
            question = suggestion.find('suggestion').attrib.get('data')
            questionResults.append(question)
        return questionResults
# Get a Keyword From The User
userInput = input("Enter a Keyword: ")
# Create Object of the QuestionsExplorer Class
qObj = QuestionsExplorer()
# Call The Method and pass the parameters
questions = qObj.GetQuestions("is", userInput, "us")
# Loop over the list and pring the questions
for result in questions:
    print(result)
print("Done")
#end

Download Full Souce Code in Python or check it out on Github (Python).

Keyword Research Tool in C#

I Tried To Implement The Code in the same way as in Python. First, we create the class, and it has a method.

//start
class QuestionsExplorer
    {
        public List<string> GetQuestions(string questionType, string userInput, string countryCode)
//end

Then, we create an object of the QuestionExplorer class in the Program’s Main Method. The GetQuestion method is called.

The complete Source code is below.

Keyword Research Tool in C# (Source code)

//start
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Xml.Linq;
namespace GoogleSuggestion
{
    //Define Class
    class QuestionsExplorer
    {
        public List<string> GetQuestions(string questionType, string userInput, string countryCode)
        {
            var questionResults = new List<string>(); //List To Return
            //Build Google Search Query
            string searchQuery = questionType + " " + userInput + " ";
            string googleSearchUrl =
            "http://google.com/complete/search?output=toolbar&gl=" + countryCode + "&q=" + searchQuery;
            //Call The URL and Read Data
            using (HttpClient client = new HttpClient())
            {
                string result = client.GetStringAsync(googleSearchUrl).Result;
                //Parse The XML Documents
                XDocument doc = XDocument.Parse(result);
                foreach (XElement element in doc.Descendants("CompleteSuggestion"))
                {
                    string question = element.Element("suggestion")?.Attribute("data")?.Value;
                    questionResults.Add(question);
                }
            }
            return questionResults;
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            //Get a Keyword From The User
            Console.WriteLine("Enter a Keyword:");
            var userInput = Console.ReadLine();
            //Create Object of the QuestionsExplorer Class
            var qObj = new QuestionsExplorer();
            //Call The Method and pass the parameters
            var questions = qObj.GetQuestions("what", userInput, "us");
            //Loop over the list and pring the questions
            foreach (var result in questions)
            {
                Console.WriteLine(result);
            }
            //Finish
            Console.WriteLine();
            Console.WriteLine("---Done---");
            Console.ReadLine();
        }
    }
   
}
//end

Check the code out on GitHub (C#) or Download the Full Source Code in C#.

Conclusion

In this post, I showed you how you could build a keyword research tool based on Google’s Suggestion API with the power of two popular programming languages, C# and Python.

Maybe you are wondering how to get search metrics like CPC, Monthly Search Volume, and Competition. The answer is in this post, where you will learn how to use Google Ads API to get these metrics.

Take care and Happy Coding!

๐ŸŸฅMaster the Most In-Demand Skill of the Future!

Enroll in the ‘Become a Prompt Engineer‘ program. We’ll take you from novice to expert in scripting AI workflows. Start your journey here!

What Will You Get?

  • Access to our premium Prompt Engineering Course
  • Access our private support forum to get help along your journey.
  • Access to our Premium Tested Prompts Library.
nv-author-image

Hasan Aboul Hasan

Digital Entrepreneur with 8+ years' experience, Founder & Developer of PromoterKit. Helping Digital Marketers to achieve 10X results using AI and Automation.

12 thoughts on “Develop a Keyword Research Tool With C# & Python”

  1. It’s very helpful for me as a website designer and content writer. I am going to build my own keyword research tool soon with this tutorial and help others too via it! Thank you, Hasan for the resoruces and I am a subscriber of your Youtube channel and the Chatgpt prompt engineering course by you have made my life easier and my professional career is on Cloud-9 after I learnt it! Thanks!

      1. Hello,

        Your videos Are awesome and would like to know that can we run source code with any hosting provider like godady ans hostinger for creating keyword tool for users

          1. Hello Hasan Sir ,

            Your videos are much much worth it. Can you please create a step by step video for creating front end and backend tool using any API keys for creating too having help of webflow , bubble and netlify ( no code tools ) which will help for targeting users use to get to know more information…about their questions..

Leave a Reply

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

Take Your Digital Marketing Skills To The Next Level

ยฉ 2023 LearnWithHasan | All Rights Reserved.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

๐Ÿ”ด New Series Started: Programming With AI - RJP Technique
This is default text for notification bar