How to Find the Keywords Your Competitors Rank For (and You Don't) with Python
A keyword gap is the list of Google searches your competitors rank for while your site doesn't show up at all. It's one of the quickest ways to find content worth writing: someone has already shown there's demand and that the query can be won. Most SEO suites put this report behind a monthly plan. This post shows a pay-per-result way to get the same list from Python, what a real run returns, and…
A keyword gap represents the set of Google searches that your competitors rank for, while your website does not appear in the search results. Finding this gap helps identify content opportunities, as someone has shown demand for these queries, and it can be won. Traditional SEO tools often charge monthly fees for this report. This article demonstrates how to obtain the same list exclusively using Python, an example output, and the limitations of the data.
To build a keyword gap, first gather ranking data for each competitor's keywords in the top N (for example, top 20) in a specific country. Next, pull what your own domain ranks for in the top 100. Compare the two sets, retaining competitor keywords that your domain is missing, removing duplicate keywords across competitors, and sorting them by volume or estimated traffic.
The challenging part is obtaining a comprehensive database of Google rankings per domain. Instead of scraping Google yourself, which is slow and gets blocked, use a ranking database service like Apify.
In the provided Python code, import the necessary libraries, set up the ApifyClient with your API token, and call the Apify Actor "steady-scrape/competitor-keywords-gap" with specific input parameters: your domain, competitors, mode (gap), location (US), language (en), and maximum number of rows per domain (150). Then, iterate through the results and print the keyword, search volume, keyword difficulty, best competitor position, number of competitors, and other relevant data.
After running the Actor, you will receive a list of gap keywords. In the test run conducted on November 3, 2026, 287 gap keywords were found in approximately 4 seconds, with 150 keywords fetched per competitor. Out of 44,530 and 8,144 available keywords for the competitors, only 287 were returned. Thirteen keywords were ranked by both competitors, mostly backlink-checking searches.
For instance, "check incoming links" had search volume of 135,000 monthly US searches and difficulty level of 51, ranking at #3 for semrush.com and #5 for moz.com, while mangools.com did not appear in the top 100.
The cost of using this Python script is $1.19 at the list price, which includes charges for keyword results ($0.004 per row) and domain analysis ($0.02 per competitor or domain queried). While the raw list provides extensive data, filtering out less relevant keywords such as navigational searches, intent labels, keyword contains, max keyword difficulty, and search intent can help focus on more actionable keywords for your content plan. The Actor also offers other modes, such as shared keywords, ranked keywords, and competitors.
It's essential to know that this data is a monthly-refreshed snapshot of Google rankings, not live search results. Positions may be a few weeks old, and the data only covers organic Google results. The keyword gap analysis is limited to one country and language per run, and search volumes, difficulty, and traffic are estimates rather than exact figures from competitors' analytics.
Additionally, small or new domains may have fewer ranked keywords to compare. Finally, the cost of using the Python script is based on the Apify Free plan, with prices increasing for higher-tier plans.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.