Live data from Hacker News

Parsing HTML Using Regular Expressions

stackoverflow.com

1–10 of 18 posts

Re: Parsing HTML Using Regular Expressions

#2
you know when you first read that you think - damn straight you can't parse html with regex, but as it goes on the idea gets strangely enticing. I mean maybe, with the correct rituals, and a gun and a willingness to fight with ancient evils you could maybe parse some html with regex. A sort of Lovecraft/Action flick.

Re: Parsing HTML Using Regular Expressions

#4

you know when you first read that you think - damn straight you can't parse html with regex, but as it goes on the idea gets strangely enticing. I mean maybe, with the correct rituals, and a gun and a willingness to fight with ancient evils you could maybe parse some html with regex. A sort of Lovecraft/Action flick.

Using regex in python to scrape some data from a website works just fine for me... shrugs

Re: Parsing HTML Using Regular Expressions

#5
post #4

you know when you first read that you think - damn straight you can't parse html with regex, but as it goes on the idea gets strangely enticing. I mean maybe, with the correct rituals, and a gun and a willingness to fight with ancient evils you could maybe parse some html with regex. A sort of Lovecraft/Action flick.

Using regex in python to scrape some data from a website works just fine for me... shrugs

yep me too, no problem.

Re: Parsing HTML Using Regular Expressions

#6
post #4

you know when you first read that you think - damn straight you can't parse html with regex, but as it goes on the idea gets strangely enticing. I mean maybe, with the correct rituals, and a gun and a willingness to fight with ancient evils you could maybe parse some html with regex. A sort of Lovecraft/Action flick.

Using regex in python to scrape some data from a website works just fine for me... shrugs

beautiful soup is a better tool.

Regex is fine for grabbing something in a page that you have looked at yourself.

Parsing millions of pages you don't have this option, you need something robust, a tool that is flexible, that doesn't barf out too many errors, that is quick.

Re: Parsing HTML Using Regular Expressions

#7
post #4

you know when you first read that you think - damn straight you can't parse html with regex, but as it goes on the idea gets strangely enticing. I mean maybe, with the correct rituals, and a gun and a willingness to fight with ancient evils you could maybe parse some html with regex. A sort of Lovecraft/Action flick.

Using regex in python to scrape some data from a website works just fine for me... shrugs

It’s an acceptable choice for scraping, because with scraping you usually go into it with the expectation that it will break and need updates sometimes as the scraped site changes. The warning bells are more for things like validating user input on your own site, where there might be security implications of an impossible parsing task.

Re: Parsing HTML Using Regular Expressions

#8
This is a fun (and classic) thread and it's worth reading the pro and con arguments.

It really falls under the old joke "you have a problem and you decide to solve it with regex, now you have two problems". HTML is very gnarly, and regex is very gnarly. Doesn't mean you can't get shit done if you're aware of the pitfalls.

Re: Parsing HTML Using Regular Expressions

#10
post #4

you know when you first read that you think - damn straight you can't parse html with regex, but as it goes on the idea gets strangely enticing. I mean maybe, with the correct rituals, and a gun and a willingness to fight with ancient evils you could maybe parse some html with regex. A sort of Lovecraft/Action flick.

Using regex in python to scrape some data from a website works just fine for me... shrugs

And I use a handgun to hunt houseflies in my motel room after a week long crystal meth binge. Works just fine for me.
Post reply on HN