Find keyword position in the google search result + python

As the world becomes increasingly digital, more and more businesses rely on search engine optimization to drive traffic to their websites. In order to optimize their website for search engines, website owners need to know the position of their keywords in Google search results. This can be a laborious process for businesses to do manually.

Fortunately, there is a Python script that can automate the process of finding the position of keywords in Google search results. This script can be a useful tool for SEO experts, website owners, and digital marketing professionals. In this post, we will walk through the steps to use this script to find the position of keywords in Google search results.

 

Files in the repository

The repository contains 6 files, each with its own unique purpose. (Repository link)

  • find.py: The main file that contains the function to find the position of a keyword in Google search results
  • header.json: Contains the HTTP headers required to send the HTTP request.
  • main.py: The file that calls the function in find.py to find the position of a list of keywords in Google search results
  • output.py: The file that generates the CSV file containing the results of the search
  • read.py: The file that contains the function to read JSON data from a file
  • keyword.json: The file that contains the domain and the list of keywords

 

Using the find.py file

The find.py file contains the function to find the position of a keyword in Google search results. The function takes in two parameters, the domain and the keyword. It returns a list of tuples, each tuple containing the position of the keyword and the URL of the webpage where the keyword was found.

The function works by sending an HTTP request to Google with the keyword and then parsing the HTML response to find the links that match the domain. It then extracts the position of the links and returns them in a list.

Using the main.py file The main.py file is responsible for calling the function in find.py to find the position of a list of keywords in Google search results. It reads the list of keywords from the keyword.json file and passes them to the find_keyword_position function.

If the show_output variable is set to True, the script will print the results to the console. If set to False, the script will call the generate_csv function in output.py to generate a CSV file containing the results.

Running the script To use this script, start by installing the requirements by running the following command in the terminal:

pip install -r requirements.txt

Next, open the keyword.json file and change the domain to the domain you want to search in and add your keywords to the list. Once you have entered your domain and keywords, save the file.

Finally, run the Python script by running the following command in the terminal:

python3 main.py

This will execute the main.py file and generate the results either in the console or in a CSV file, depending on the value of the show_output variable.

 

Conclusion

Using the Python script outlined in this post can save SEO experts, website owners, and digital marketing professionals valuable time by automating the process of finding the position of keywords in Google search results. By using this script, businesses can focus on optimizing their website for search engines, driving traffic to their website, and increasing their online visibility.

 

Links:

 

Note: Hahahahaha, This blog post was generated by Chat-GPT. Thank you Open-AI.