3 ms·
Only if you care about absolute accuracy in sufficiently complex pages. There are many use cases I can think of that really don't.
by AnIdiotOnTheNet 6y ago
Only if you care about absolute accuracy in sufficiently complex pages. There are many use cases I can think of that really don't.
- TeMPOraL 6y agoParsing 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.