Re: Beautiful Soup Looping Extraction Question

2008-03-25 Thread Stefan Behnel
Hi, again, not BS related, but still a solution. Tess wrote: > Let's say I have a file that looks at file.html pasted below. > > My goal is to extract all elements where the following is true: align="left"> and . Using lxml: from lxml import html tree = html.parse("file.html") for el in

Re: Beautiful Soup Looping Extraction Question

2008-03-25 Thread Tess
Paul - you are very right. I am back to the drawing board. Tess -- http://mail.python.org/mailman/listinfo/python-list

Re: Beautiful Soup Looping Extraction Question

2008-03-24 Thread Paul McGuire
On Mar 24, 7:56 pm, Tess <[EMAIL PROTECTED]> wrote: > > Anyhow, a simple regex took care of the issue in BS: > > for i in soup.findAll(re.compile('^p|^div'),align=re.compile('^center| > ^left')): >     print i > But I thought you only wanted certain combinations: "My goal is to extract all elem

Re: Beautiful Soup Looping Extraction Question

2008-03-24 Thread Tess
Paul - thanks for the input, it's interesting to see how pyparser handles it. Anyhow, a simple regex took care of the issue in BS: for i in soup.findAll(re.compile('^p|^div'),align=re.compile('^center| ^left')): print i Thanks again! T -- http://mail.python.org/mailman/listinfo/python-li

Re: Beautiful Soup Looping Extraction Question

2008-03-24 Thread Paul McGuire
On Mar 24, 6:32 pm, Tess <[EMAIL PROTECTED]> wrote: > Hello All, > > I have a Beautiful Soup question and I'd appreciate any guidance the > forum can provide. > I *know* you're using Beautiful Soup, and I *know* that BS is the de facto HTML parser/processor library. Buut, I just couldn't help

Beautiful Soup Looping Extraction Question

2008-03-24 Thread Tess
Hello All, I have a Beautiful Soup question and I'd appreciate any guidance the forum can provide. Let's say I have a file that looks at file.html pasted below. My goal is to extract all elements where the following is true: and . The lines should be ordered in the same order as they appear in