Skip to content

A simple Python script to find the Google search rank of a given website domain for a specific search term.

License

Notifications You must be signed in to change notification settings

bendiep/python-google-rank-finder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python-google-search-rank

A simple Python script that checks the Google Search Ranking of a given domain for a specific keyword or phrase.

It supports the following Search APIs:

📋 Prerequisites

Depending on which Search API you choose, you’ll need one of the following:

Option 1: SerpApi

  • A SerpApi API Key is required (can be created here)

Option 2: Google Custom Search API

  • A Google Custom Search API Key and Engine ID is required (both can be created here)

📦 Installation

  1. Clone the repository:

    git clone https://github.com/bendiep/python-google-rank-finder.git
    cd python-google-rank-finder
  2. Install the required packages:

    pip install -r requirements.txt
  3. Set up your environment variables based on the Search API you plan to use:

    # For SerpApi
    export SERPAPI_API_KEY="your-serpapi-api-key"
    
    # For Google Custom Search API
    export GOOGLE_CUSTOM_SEARCH_API_KEY="your-google-custom-search-api-key"
    export GOOGLE_CUSTOM_SEARCH_ENGINE_ID="your-google-custom-search-engine-id"

▶️ Usage

Run the script with the following command:

python google-rank-finder.py <website_domain> <search_term>

e.g.
python google-rank-finder.py "instagram.com" "ig"

Optional arguments:

--country: Specify the country code

python google-rank-finder.py <website_domain> <search_term> --country AU

--max_pages: Set the maximum number of pages to search (default: 10).

python google-rank-finder.py <website_domain> <search_term> --max_pages 3

--api: Choose the Search API to use (SERPAPI or GOOGLE_CUSTOM_SEARCH). Default is SERPAPI.

python google-rank-finder.py <website_domain> <search_term> --api GOOGLE_CUSTOM_SEARCH

📂 Example Output

python google-rank-finder.py "instagram.com" "ig"
Google Search Rank (via. SERPAPI):
page: 1, rank: 1, url: https://www.instagram.com/

📝 License

Released under the MIT License. Feel free to use, modify, and share!

About

A simple Python script to find the Google search rank of a given website domain for a specific search term.

Resources

License

Stars

Watchers

Forks

Languages