Develop a Keyword Research Tool For Free With C# & Python

Develop a Keyword Research Tool

Table of Contents

Spread the love

How to Develop a Keyword Research Tool with Python and C#? 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.

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, doesn’t it?

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 a Keyword Research Tool with Python or C#.

So, what are those two websites?

How does “Answerthepublic.com” Works?

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 keywords that people have searched for on the search engines and especially 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 just want to stay away from it! Don't you?????

Develop a Keyword Research Tool like answerthepublic
AnswerthePublic.com

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.

Develop a Keyword Research Tool like keywordtool.io
Keywordtool.io

Simply, 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, then 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.

keywordtool.io search example
Keywordtool.io searching for keyword ex “python tutorial”

Let’s open Google and type the same query we type into KeywordTool.io

Type “Python Tutorialpress space and type the letter “f”, you will see Google suggests keywords, ideas, and search queries!

google search suggestions

That’s how it works.

How AnswerthePublic.com is getting Results for Question suggestions?

answerthepublic questions

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.

Develop a Keyword Research Tool (google question suggestions)
Google Question Suggestions

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, so things will be complicated.

API Call for Google Keyword Suggestions:

If you open your browser and paste this URL, you will simply 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:

Develop a Keyword Research Tool (google suggestions api)
Google Suggestions API Results

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 of all, 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 in 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 Main Method of the Program. 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 Full Source Code in C#.

Conclusion

In this post, I showed you how you can 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.

Don't FORGET To join me on YouTube:

Subscribe To My Channel To Get All Updates

Thanks!

Take care, and Happy Coding! If you have questions or want to discuss anything related to this project, I will be happy to chat with you on our forum.


Spread the love