Python script to check keyword density and placement in HTML articles
A DEV Community article presents a small Python script for content teams that checks keyword density and where a target keyword appears in an HTML page, without needing an SEO plugin. The author argues that keyword placement matters more than raw occurrence counts, so the script prioritizes checks on the title, URL slug, and opening paragraph. Placement is grouped into required, recommended, and natural tiers, which the script reports as errors or suggestions. Because Google publishes no official density target, the script treats density above about 3% only as a warning flag. The code handles Vietnamese diacritics by normalizing text for URL matching and uses BeautifulSoup to parse page elements.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in