No release in over a year
A simple Ruby CLI and in-code SEO position tracking tool for Google and 5 other search engines.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Ruby SEO Position Tracker

A simple Ruby CLI and in-code SEO position tracking tool for Google and 5 other search engines.

This tool uses SerpApi as a tool to parse data from search engines.

You can use provided API key that will be available after installation, however, it's purely for testing purposes to see if the tool fits your needs. If you'll be using it for your own purpose (personal or commercial), you have to use your own SerpApi key.

🔎 Current search engines support

  • Google Search - first 100 organic results.
  • Bing Search - first 50 organic results.
  • DuckDuckGo Search - up to 30 organic results.
  • Yahoo! Search - first 10 organic results.
  • Yandex Search - up to 15 organic results.
  • Naver Search - first 15 organic results.

⚙️Installation

$ gem install seo-position-tracker-ruby

🤹‍♂️Usage

$ seo -h
Available arugments
Usage: seo [options]
    -q, --query QUERY                Search query. Default "coffee".
    -k, --target-keywords KEYWORDS   Target keywords to track. Default "coffee".
    -w, --target-websites WEBSITES   Target websites to track. Default "starbucks.com".
    -e, --search-engine ENGINES      Choosing a search engine to track: "google", "bing", "duckduckgo", "yahoo", "yandex", "naver". You can select multiple search engines by separating them with a comma: google,bing. All search engines are selected by default.
    -a, --api-key API_KEY            Your SerpApi API key: https://serpapi.com/manage-api-key. Default is a test API key to test CLI.
    -l, --language LANGUAGE          Language of the search. Supported only for "google", "yahoo" and "yandex" engines. Default is nil.
    -c, --country COUNTRY            Country of the search. Supported only for "google", "bing" and "yahoo" engines. Default is nil.
    -p, --location LOCATION          Location of the search. Supported only for "google", "bing", "duckduckgo" and "yandex" engines. Default is nil.
    -d, --domain DOMAIN              Search engine domain to use. Supported only for "google", "yahoo" and "yandex" engines. Default is nil.
    -s, --save-to SAVE               Saves the results in the current directory in the selected format (CSV, JSON, TXT). Default CSV.

🤹‍♂️Examples

Extracting positions from all search engines for a given query with a target website and a target keyword:

$ seo --api-key=<your_serpapi_api_key> \
-q "minecraft" \
-k official \
-w minecraft.net
[
  {
    "engine": "google",
    "position": 1,
    "title": "Welcome to the Minecraft Official Site | Minecraft",
    "link": "https://www.minecraft.net/en-us"
  },
  {
    "engine": "bing",
    "position": 1,
    "title": "Welcome to the Minecraft Official Site | Minecraft",
    "link": "https://www.minecraft.net/"
  },
  {
    "engine": "duckduckgo",
    "position": 1,
    "title": "Welcome to the Minecraft Official Site | Minecraft",
    "link": "https://www.minecraft.net/"
  },
  {
    "engine": "yahoo",
    "position": 1,
    "title": "Welcome to the Minecraft Official Site | Minecraft",
    "link": "https://www.minecraft.net/"
  },
  {
    "engine": "yandex",
    "position": 1,
    "title": "Welcome to the Minecraft Official Site | Minecraft",
    "link": "https://www.minecraft.net/"
  }
]

Extracting positions from 3 search engines with default arguments and saving to CSV:

$ seo --api-key=<your_serpapi_api_key> \
-e google,bing,duckduckgo \
-s CSV
[
  {
    "engine": "google",
    "position": 7,
    "title": "Starbucks Coffee Company",
    "link": "https://www.starbucks.com/"
  },
  {
    "engine": "bing",
    "position": 4,
    "title": "Starbucks Coffee Company",
    "link": "https://www.starbucks.com/"
  },
  {
    "engine": "bing",
    "position": 13,
    "title": "The Best Coffee from Starbucks Coffee: Starbucks Coffee Company",
    "link": "https://www.starbucks.com/coffee/"
  },
  {
    "engine": "duckduckgo",
    "position": 2,
    "title": "Starbucks Coffee Company",
    "link": "https://www.starbucks.com/"
  },
  {
    "engine": "duckduckgo",
    "position": 11,
    "title": "The Best Coffee from Starbucks Coffee: Starbucks Coffee Company",
    "link": "https://www.starbucks.com/coffee/"
  }
]

Extracting positions from one engine with all arguments for it:

$ seo --api-key=<your_serpapi_api_key> \
-q serpapi \
-k "Google Search API" \
-w "https://serpapi.com/" \
-e google \
-l de \
-c de \
--location Germany \
-d google.de \
-s txt
[
  {
    "engine": "google",
    "position": 1,
    "title": "SerpApi: Google Search API",
    "link": "https://serpapi.com/"
  }
]

Extracting positions from all search engines manually (without CLI):

require "seo-position-tracker-ruby"

tracker = SeoPositionTracker::Scraper.new(
    query='coffee', 
    api_key='<your_serpapi_api_key>', 
    keywords=['coffee', 'starbucks'], 
    websites=['starbucks.com', 'wikipedia.org']
)

position_data = []

google_results = tracker.scrape_google(lang='en', country='us', location='United States', domain='google.com')
position_data.concat(google_results)

bing_results = tracker.scrape_bing(country='us', location='United States')
position_data.concat(bing_results)

duckduckgo_results = tracker.scrape_duckduckgo(location='us-en')
position_data.concat(duckduckgo_results)

yahoo_results = tracker.scrape_yahoo(lang='lang_en', country='us', domain='uk')
position_data.concat(yahoo_results)

yandex_results = tracker.scrape_yandex(lang='en', domain='yandex.com')
position_data.concat(yandex_results)

naver_results = tracker.scrape_naver()
position_data.concat(naver_results)

tracker.save_to_csv(position_data)
tracker.save_to_json(position_data)
tracker.save_to_txt(position_data)

tracker.print(position_data)

💡Issues or suggestions

Visit issues page.

📜 Licence

Ruby SEO Position Tracker is released under the BSD-3-Clause Licence.