Lee Foot

SERP N-gram Extractor

Find the most common word pairs on the pages ranking for a keyword, plus the words their titles share.

Launch the app → View the source

#about

Shows the ten most common word pairs (bigrams) across the pages ranking for a keyword, and the words used more than once in their titles.

One DataForSEO search fetches 10 to 100 results, at an estimated $0.0006 per 10, and you collect it with the job file once it finishes, which can take 25 minutes or more.

Trafilatura extracts each page's text, which is lowercased and stripped of NLTK English stopwords before counting.

Title word counts are case-sensitive, and pages that fail to download are skipped without a report.

Streamlit app

Platform
Browser-based (no installation required)
Input
DataForSEO login and passwordTarget search keywordGeographic locationDevice type (Desktop or Mobile)
Output
Three CSVs: bigrams.csv (the top 10 content bigrams, each with its count in the same cell), title_keywords.csv (keyword, frequency, for words that appear more than once across the titles) and serp_titles.csv (title, url).
Category
Content

Use cases

  • Content gap analysis
  • Page title optimisation
  • Understanding SERP content patterns
  • Competitive content research

#features

  • DataForSEO Standard queue: one search per run, sent now and collected later, estimated cost shown
  • Trafilatura content extraction with timeout disabled
  • Bigram (two-word) generation from combined page content
  • NLTK English stopwords filtering
  • Top 10 bigrams by frequency exported to CSV
  • 10 preset search regions; Desktop or Mobile device

#how-to-use

  1. Enter your DataForSEO login and password in the sidebar
  2. Input target keyword and select a region
  3. Choose device type and how many top results to fetch (10-100)
  4. Click Send search and download the job file
  5. About 30 minutes later, collect the results with the job file
  6. Trafilatura extracts text from each ranking page
  7. Review bigrams, title keywords and extracted titles
  8. Download the three CSV files for content planning

#faq

Why does it take two steps?
Google now routes result links through google.com/goto, and DataForSEO's instant (Live) requests leave many of them unresolved, so the real URL and domain are missing. Its Standard queue resolves them, but a search can take 25 minutes or more. So the tool sends the searches and gives you a job file, and you collect the results from that file later. DataForSEO keeps finished searches for 30 days.
Why does the bigrams download only contain 10 rows?
The code keeps only the 10 most common word pairs (Counter.most_common(10)) from the combined page content, so the bigrams CSV is a top-10 shortlist, not an exhaustive frequency table. Only two-word bigrams are generated; there is no setting for longer n-grams.
How much does one analysis cost?
One DataForSEO search per keyword. The pages slider is multiplied by 10 and sent as the depth, so selecting 3 pages fetches the top 30 results in one search. The estimate is $0.0006 per 10 results and is shown before you send. A search can take 25 minutes or more, so you collect the results later with the job file; collecting costs nothing.
Why do fewer URLs appear in the results than in the SERP?
Pages that fail to download or extract (blocked bots, 403s, timeouts) are silently skipped; there is no error report. Results that come back as unresolved google.com/goto links are never fetched, and a warning gives their count. The remaining pages are extracted with Trafilatura with its extraction timeout disabled, so a very heavy page can also make the run feel stuck rather than fail.
How are the title keywords counted?
All fetched page titles are concatenated, special characters are replaced with spaces, and single words appearing more than once are kept. Titles are not lowercased first, so the count is case-sensitive: Shoes and shoes are tallied separately. Page content, by contrast, is lowercased and has NLTK English stopwords removed before bigram counting.
Where is each bigram's count?
In the same cell as the bigram. bigrams.csv has one column, and each row holds the two words followed by the count, for example (('running', 'shoes'), 12). Split the column in a spreadsheet if you need the count on its own. Only two-word phrases are produced; the length is fixed in the code. Searches can be run from ten preset regions on desktop or mobile, always in English.

/contact

Want me to run this for you? I run this tool as a managed service, or build something custom around your data. You get the insights without touching the code.