DEV Community

Cover image for How to build a rank tracker with python
SerpApi.Org
SerpApi.Org

Posted on • Originally published at serpapi.org

How to build a rank tracker with python

After a decade of building marketing automation tools, I’ve learned that the biggest hurdle in monitoring search positions isn't the code itself—it’s the cat-and-mouse game against Google’s anti-bot infrastructure. Over 90% of custom scrapers fail within their first 100 requests due to modern TLS fingerprinting. If you are planning to build your own tracking solution, here is the architectural breakdown.

The Blocking Problem: It’s Not Just Your IP

Google identifies automated traffic by analyzing your "JA3 fingerprint." When you use standard libraries like requests, the SSL handshake reveals specific cipher suites and extensions that don't match standard browsers.

  • The Fix: Move away from raw requests. Libraries like curl_cffi allow you to mimic the TLS client hello characteristics of Chrome or Firefox, which helps you slip past initial triggers.
  • The Proxy Trap: Cloud hosting (AWS, DigitalOcean) is easily flagged. If you go the manual route, you must use residential proxy pools, though this adds significant operational costs.

Choosing Your Engine

The trade-off is between resource overhead and maintenance.

Feature BeautifulSoup Playwright SERP API
JS Support None Full Full
Maintenance High (DOM changes) Medium Zero
Proxy Cost High High Included

For hobby projects, BeautifulSoup is lightweight and fast, but Google changes its DOM structure frequently, which will break your selectors. Playwright handles dynamic content but is resource-heavy and requires more stealth (to hide automation flags). For production-grade data, offloading this to a dedicated SERP API is usually the most cost-effective path when you calculate the hours spent on maintenance.

Precision Targeting with UULE

To get local rankings, you cannot rely on IP geolocation. You need to use the UULE parameter. This is a Base64-encoded string that tells Google exactly which location to simulate.

  1. Use Google’s Geotargets list to find the canonical name (e.g., "Chicago,Illinois,United States").
  2. Calculate the string length and map it to a specific ASCII character key.
  3. Concatenate the prefix w+CAIQICI + your character key + Base64-encoded location.
  4. Pass this in your URL as &uule=....

Storing Data for Insights

Don't use CSVs for tracking; they lack the relational integrity needed for time-series analysis. Use SQLite to build a schema that separates keywords, runs (with timestamps), and rankings. This allows you to run SQL queries to calculate movement trends over 30 or 90 days—which is the actual value an SEO professional needs.

Automation via GitHub Actions

Stop paying for VPS instances. You can automate your scraper for free using GitHub Actions. Create a YAML file in .github/workflows/ and use a cron trigger:

on:
  schedule:
    - cron: '0 4 * * *' # Runs at 4:00 AM daily
Enter fullscreen mode Exit fullscreen mode

Use GitHub Encrypted Secrets to store your proxy credentials or API keys. This keeps your pipeline secure while ensuring your data logs are updated automatically every day.

Building a tracker is a rite of passage for any developer in the SEO space. Just remember: the architecture you choose today determines how much time you'll spend "fixing" your code next month. Choose your dependencies wisely.


Originally published at How to build a rank tracker with python

Top comments (1)

Collapse
 
topstar_ai profile image
Luis Cruz

I particularly appreciated the section on avoiding the proxy trap by using residential proxy pools, as this is a common pitfall when building custom scrapers. The comparison of BeautifulSoup, Playwright, and SERP API in terms of JS support, maintenance, and proxy costs was also very insightful, highlighting the trade-offs involved in choosing an engine for the rank tracker. One thing that might be worth exploring further is the use of machine learning models to detect and adapt to changes in Google's anti-bot infrastructure, potentially allowing for more robust and long-term solutions. Have you considered integrating any ML components into your tracker architecture?