Skip to main content

Saizul Amin

Automated SEO Keyword Rank Tracking and SERP Monitoring Engine with Python and n8n

📅 15 Sep 2026 ⏱ 4 min read
Automated SEO Keyword Rank Tracking and SERP Monitoring Engine with Python and n8n
In this article

    Commercial search engine optimization platforms (such as Ahrefs, Semrush, or AccuRanker) charge between $150 to $500 every month for basic keyword rank tracking, frequently imposing restrictive limits on the number of trackable search terms and updating rankings only once every 3 to 7 days. During volatile Google core update rollout periods, digital publishers and e-commerce brands need daily, granular ranking intelligence across both desktop and mobile SERPs without incurring exorbitant SaaS subscription costs.

    In 2026, technical marketing teams construct self-hosted keyword rank tracking engines using Python, rotating residential proxies, and n8n workflow orchestration. By programmatically inspecting Google SERP features (including AI Overviews, Featured Snippets, and Knowledge Panels), storing position histories in PostgreSQL, and dispatching weekly ranking delta summaries to Slack, businesses own their search data completely. Here is the full implementation blueprint.


    Why Self-Hosted Rank Tracking Outperforms Commercial SaaS

    Evaluating commercial rank tracking tools against a dedicated self-hosted pipeline:

    Operational Metric Commercial SEO SaaS (Ahrefs / Semrush) Self-Hosted Rank Engine (Python + n8n)
    Tracking Frequency Weekly (unless paying premium $300+/mo daily tier) Daily or hourly on-demand
    SERP Feature Detection Standard organic ranking only Tracks AI Overviews (SGE), Local Packs, and Video Carousels
    Keyword Volume Limits 500 to 1,500 keywords capped by subscription Unlimited; pay only pennies for proxy bandwidth
    Monthly Infrastructure Cost $200 – $600 / month $12 / month (VPS + proxy credits)

    Step 1: The Python SERP Extraction Engine (`serp_tracker.py`)

    Using Python with rotating residential proxies to scrape Google search results while avoiding CAPTCHA blocks:

    # tracker/serp_tracker.py
    import requests
    from bs4 import BeautifulSoup
    import urllib.parse
    import json
    import sys
    
    def check_keyword_ranking(target_domain: str, keyword: str):
        encoded_query = urllib.parse.quote_plus(keyword)
        search_url = f"https://www.google.com/search?q={encoded_query}&num=50&hl=en"
        
        # Configure rotating residential proxy endpoint
        proxies = {
            "http": "http://user:pass@proxy.residential-network.com:8080",
            "https": "http://user:pass@proxy.residential-network.com:8080"
        }
    
        headers = {
            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
            "Accept-Language": "en-US,en;q=0.9"
        }
    
        try:
            response = requests.get(search_url, headers=headers, proxies=proxies, timeout=15)
            response.raise_for_status()
            
            soup = BeautifulSoup(response.text, "html.parser")
            search_results = soup.find_all("div", class_="yuRUbf")
    
            detected_rank = None
            ranked_url = None
    
            for index, result in enumerate(search_results, start=1):
                link = result.find("a")
                if link and "href" in link.attrs:
                    url = link["href"]
                    if target_domain in url:
                        detected_rank = index
                        ranked_url = url
                        break
    
            return {
                "keyword": keyword,
                "target_domain": target_domain,
                "rank": detected_rank if detected_rank else 0, # 0 means not in top 50
                "ranked_url": ranked_url if ranked_url else "Not Ranked"
            }
    
        except Exception as e:
            return {"error": str(e), "keyword": keyword}
    
    if __name__ == "__main__":
        kw = sys.argv[1] if len(sys.argv) > 1 else "nextjs 15 server actions benchmark"
        domain = sys.argv[2] if len(sys.argv) > 2 else "saizulamin.com"
        result = check_keyword_ranking(domain, kw)
        print(json.dumps(result))

    Step 2: Storing Ranking Histories in PostgreSQL

    Track rank volatility, historical progression, and ranking URLs over time:

    -- Daily ranking telemetry schema
    CREATE TABLE keyword_rank_history (
        id BIGSERIAL PRIMARY KEY,
        keyword VARCHAR(255) NOT NULL,
        target_domain VARCHAR(100) NOT NULL,
        current_rank INT NOT NULL,
        ranked_url TEXT,
        recorded_date DATE DEFAULT CURRENT_DATE
    );
    
    CREATE INDEX idx_kw_domain_date ON keyword_rank_history (target_domain, keyword, recorded_date DESC);

    Step 3: Orchestrating the n8n Daily Workflow

    The n8n workflow executes daily at 06:00 AM UTC:

    1. PostgreSQL Query Node: Fetches all tracked keywords for saizulamin.com and saizul.com.
    2. Execute Command Node: Runs python3 serp_tracker.py "$json.keyword" "$json.domain".
    3. PostgreSQL Insert Node: Records the new rank in keyword_rank_history.
    4. Rank Movement Calculator: Compares yesterday’s rank against today’s rank. If a keyword jumped into the Top 3 or dropped more than 5 positions, triggers a Slack alert.
    {
      "blocks": [
        {
          "type": "header",
          "text": { "type": "plain_text", "text": "🎯 Daily SEO Keyword Movement Alert" }
        },
        {
          "type": "section",
          "fields": [
            { "type": "mrkdwn", "text": "*Keyword:* " + $json.keyword },
            { "type": "mrkdwn", "text": "*Domain:* " + $json.target_domain },
            { "type": "mrkdwn", "text": "*New Rank:* #" + $json.rank + " (Delta: " + $json.delta + ")" },
            { "type": "mrkdwn", "text": "*URL:* <" + $json.ranked_url + "|View Page>" }
          ]
        }
      ]
    }

    Conclusion

    Owning your SEO rank intelligence provides unmatched agility. By pairing lightweight Python extraction scripts with self-hosted n8n workflows and PostgreSQL time-series analytics, digital publishers track thousands of keywords with zero SaaS subscription fees, detect algorithm update impacts in real time, and protect their organic traffic moat.

    Share this article
    Md Saizul Amin
    Written by

    Digital Systems Strategist · AI Agent Developer · 9+ years in digital & IT

    Md Saizul Amin is a digital systems strategist and AI automation engineer from Dhaka, Bangladesh. With 9+ years across IT, web development and digital marketing, he writes practical guides on technology, business, education and online growth — and builds the same kinds of systems (AI agents, websites, SEO and ad campaigns) for clients in Bangladesh, the UK and the USA.

    9+Years in digital & IT
    50+Websites developed
    7Live AI agent systems
    $150K+Ad spend managed

    Specialist in

    AI agents & n8n automationLLM integration (Gemini, GPT-4o, Claude)Custom software & web appsWordPress developmentSEO · AEO · GEOMeta & Google AdsEmail deliverabilityCRM & funnelsIT infrastructure & cybersecurity

    Credentials & experience

    • 🎓
      B.Sc. in Computer Science & EngineeringBangladesh University of Business & Technology (BUBT), 2017–2021
    • 🤖
      AI Automation Engineer · Web Developer · SEO SpecialistUnique Mark Limited, Birmingham UK — 2024 to present
    • 🌱
      IT SpecialistGreen Fund Initiative Inc., USA — 2024 to present
    • 🏥
      Junior IT Consultant — Ministry of Health (DGHS)Built the first national Shareable Health Record website; supported 6,000+ facilities
    • 🧭
      Head of ITWEDO Bangladesh — led IT for 50+ staff, 2021–2023

    ✔ Researched and written by the author, informed by hands-on work on real projects. Articles are updated when facts, tools or guidelines change.

    Want results like this for your business?

    AI agents, custom software, websites and growth systems — let’s talk about yours.