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:
- SerpApi (Default)
- Google Custom Search API
Depending on which Search API you choose, you’ll need one of the following:
- A SerpApi
API Keyis required (can be created here)
- A Google Custom Search
API KeyandEngine IDis required (both can be created here)
-
Clone the repository:
git clone https://github.com/bendiep/python-google-rank-finder.git cd python-google-rank-finder -
Install the required packages:
pip install -r requirements.txt
-
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"
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_SEARCHpython google-rank-finder.py "instagram.com" "ig"
Google Search Rank (via. SERPAPI):
page: 1, rank: 1, url: https://www.instagram.com/
Released under the MIT License. Feel free to use, modify, and share!