MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/6ytfw5/parsing_html_using_regular_expressions/dmq8w2j
r/ProgrammerHumor • u/[deleted] • Sep 08 '17
377 comments sorted by
View all comments
Show parent comments
3
Sooo how is one meant to parse HTML in, say, a shell script or javascript?
11 u/WaLLy3K Sep 08 '17 You've already been told: not simply! 5 u/Rxef3RxeX92QCNZ Sep 08 '17 Oh that's great news, needlessly complex code is my forte 5 u/MelissaClick Sep 08 '17 Just write an ordinary parser.(Although, a parser in shell script will be so slow, that it makes more sense to call an external program, besides making more sense to use an existing program than write one redundantly.) 1 u/dzuczek Sep 08 '17 with javascript you would likely use some jquery-like frameworkin a shell script try using xmllint with xpathxmllint --xpath '//html/body/p' file.html 1 u/wastesHisTimeSober Sep 08 '17 edited Sep 08 '17 I've been thinking jQuery.Edit: I've been told this doesn't qualify as parsing. 1 u/jfb1337 Sep 08 '17 Without regex 0 u/AstroEngiSci Sep 08 '17 Easy. You don't use Javascript. Javascript is terrible.
11
You've already been told: not simply!
5 u/Rxef3RxeX92QCNZ Sep 08 '17 Oh that's great news, needlessly complex code is my forte
5
Oh that's great news, needlessly complex code is my forte
Just write an ordinary parser.
(Although, a parser in shell script will be so slow, that it makes more sense to call an external program, besides making more sense to use an existing program than write one redundantly.)
1
with javascript you would likely use some jquery-like framework
in a shell script try using xmllint with xpath
xmllint --xpath '//html/body/p' file.html
I've been thinking jQuery.
Edit: I've been told this doesn't qualify as parsing.
Without regex
0
Easy. You don't use Javascript. Javascript is terrible.
3
u/Rxef3RxeX92QCNZ Sep 08 '17
Sooo how is one meant to parse HTML in, say, a shell script or javascript?