{
  "id": 20192781,
  "title": "Build a Call-to-Action Inventory: Extract Every Button and Link Label Across Your Site With Python",
  "url": "https://urgent.news/2026/11/15/build-a-call-to-action-inventory-extract-every-button-and-link-label",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-15T15:19:03.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/ujjwal_dubey_9/build-a-call-to-action-inventory-extract-every-button-and-link-label-across-your-site-with-python-16bm"
  },
  "original_language": "en",
  "account": "A Python script can be used to gather every call-to-action (CTA) label and button/link label across a website. On the homepage, the label \"Book a free call\" is used, while the pricing page employs \"Get started.\" The footer contains \"Contact sales,\" and the blog page features \"Talk to us.\" Running this script will identify these four labels on a single page, but the same script can be extended to analyze the entire site.\n\nThe script begins by defining a class called CTA that inherits from HTMLParser. This class keeps track of the tags it encounters and appends any found buttons or links to a stack. When the parser encounters a start tag, it checks if it's a button or a link with a relevant class name, then appends it to the stack. As the parser reads the data between tags, it appends the text content to the stack's last element.\n\nWhen parsing the HTML, the script opens each URL provided, reads the HTML content, and feeds it to an instance of the CTA parser. The parser then returns a list of tuples, where each tuple contains the text of the CTA label and the URL it appears on. The script then organizes these labels by their corresponding URLs using a dictionary with a Counter object.\n\nFinally, the script iterates through the labeled URLs and prints out the results. If there's only one label on a page, it suggests using that label consistently across the site. If there are multiple labels on a page, it recommends picking the most effective one and using it everywhere. For example, \"Get started\" appears on both a pricing page and a services page but has different outcomes, causing confusion for users. Vague labels like \"Learn more\" or \"Click here\" offer no clear direction to users. The script also notes that it only reads server-rendered HTML, so if your buttons rely on JavaScript, you'll need to extract the rendered DOM first. Lastly, the script encourages combining the CTA inventory with a tone check per page to ensure consistency in messaging.",
  "summary": "A homepage might say \"Book a free call\", the pricing page \"Get started\", the footer \"Contact sales\" and the blog \"Talk to us\". Four labels for one action. A free brand audit of your page copy will flag this on one page; this script shows it across the whole site. import re , urllib . request from html . parser import HTMLParser from collections import Counter , defaultdict class CTA ( HTMLParser…",
  "key_points": [
    "Python script identifies call-to-action labels across website",
    "Script parses HTML, extracts buttons and links with relevant classes",
    "Results organized by URL, recommends consistent CTA usage"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}