---
title: "Comment by OnlineProxy on \"Why Most Table Scrapers Fail on Wikipedia (And How to Fix It)\" | Hashnode"
description: "First up, wrap that malformed rowspan stuff ,you know, the {{{}}} mess, in a try-catch that defaults to 1 if it blows up. Then, when you're pulling text, nuke t"
url: "https://hashnode.com/posts/why-most-table-scrapers-fail-on-wikipedia-and-how-to-fix-it/69983ebf61e7dc7a2a75d011/comment/6a3f7e587b4744e9f920a7a3"
---

[Discussion](https://hashnode.com/posts/why-most-table-scrapers-fail-on-wikipedia-and-how-to-fix-it/69983ebf61e7dc7a2a75d011)

Comment [Why Most Table Scrapers Fail on Wikipedia (And How to Fix It)](https://hashnode.com/posts/why-most-table-scrapers-fail-on-wikipedia-and-how-to-fix-it/69983ebf61e7dc7a2a75d011)

[OnlineProxy](https://hashnode.com/@onlineproxyio)

[Jun 27](https://hashnode.com/posts/why-most-table-scrapers-fail-on-wikipedia-and-how-to-fix-it/69983ebf61e7dc7a2a75d011/comment/6a3f7e587b4744e9f920a7a3)

First up, wrap that malformed rowspan stuff ,you know, the {{{}}} mess, in a try-catch that defaults to 1 if it blows up. Then, when you're pulling text, nuke the jQuery sortkey junk and those footnote brackets \[123\] before they trash your numeric columns. And run a cardinality check to catch horizontal duplication - because yeah, wikipedia tables sometimes legit repeat column names when they actually mean different things, not just because the layout got weird. Your detectHeaderRowIndex() function is honestly chefs kiss - it catches all those v t e variations whether they're spaced out, piped, or bracketed. I'm wondering tho if you're actually filtering out nested tables with table.tBodies or checking that row.parentElement === table, because if not, you're probably letting infobox rows slip through and mess with your column count? Anyway, if you keep iterating on this, those canonical test cases would make a killer regression suite
