Urgent.News

What's breaking now, across thousands of outlets.

Tech

Build a Call-to-Action Inventory: Extract Every Button and Link Label Across Your Site With Python

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…

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.

The 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.

When 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.

Finally, 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.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Identifiers,variables,Reserved words.

* Identifiers * A name in python program is known as identifier/variables or reference variables Rules for identifiers in Python The first character is a letter (a-z, A-Z) or an underscore _.

  • Identifiers are names for variables, functions, classes in Python
  • Must start with letter or underscore, can contain letters, digits, underscores
  • Cannot be reserved keywords like "False", "None", "True"

I Benchmarked Just My Socks on 3 Nodes. The Numbers Were Fine — My Test Method Wasn't

I Benchmarked Just My Socks on 3 Nodes. The Numbers Were Fine — My Test Method Wasn't I spent an evening benchmarking my Just My Socks subscription across three nodes, and the most interesting thing I…

  • Author conducted benchmarking session on 15th November 2026
  • Initial runs measured wrong due to script not using proxy
  • Fixed by verifying exit IP and explicitly testing through proxy

I Built 200+ Free Online Tools. Now Comes the Scary Part. 🚀

I can build websites. I can fix bugs. I can write code for hours. But can I actually build a business? That's the question that's been keeping me up at night. So I decided to find out.

  • Developer creates UsefulGo.com with 200+ free online tools and games
  • Coding was easy, mastering SEO, marketing, and analytics was challenging
  • Developer aims to build a useful tool, welcomes feedback and collaboration

More from Sunday 15 November →