regex help

Tim Harig usernet at ilthio.net
Wed Jul 8 18:43:41 EDT 2009


On 2009-07-08, Chris Rebert <clp2 at rebertia.com> wrote:
> On Wed, Jul 8, 2009 at 3:06 PM, David<david.bramer at googlemail.com> wrote:
>> I want to extract the open, mkt cap and P/E values - but apart from
>> doing loads of indivdual REs which I think would look messy, I can't
>> think of a better and neater looking way. Any ideas?

You are downloading market data?  Yahoo offers its stats in CSV format that
is easier to parse without a dedicated parser.

> Use an actual HTML parser? Like BeautifulSoup
> (http://www.crummy.com/software/BeautifulSoup/), for instance.

I agree with your sentiment exactly.  If the regex he is trying to get is
difficult enough that he has to ask; then, yes, he should be using a
parser.

> I will never understand why so many people try to parse/scrape
> HTML/XML with regexes...

Why?  Because some times it is good enough to get the job done easily.



More information about the Python-list mailing list