3 ms·
Parsing HTML with regexes is fine if you're not solving a general case. A regex "parser" will carry implicit assumptions about the document structure. Like, I
by TeMPOraL 6y ago
Parsing HTML with regexes is fine if you're not solving a general case. A regex "parser" will carry implicit assumptions about the document structure.
Like, I know "<div.+>.+foo\s+([a-z]+)" will work, because I've crafted it for a specific site whose sources I've seen.
- ziml77 6y agoNot sure why you're downvoted. What you're describing is perfectly reasonable. Like you might be scraping a page with no user-generated content. Regex can make a lot of sense because if the regex stops matching, the page probably changed enough that a parser wouldn't stop it from breaking the scraping either.