Beautiful Soup Looping Extraction Question

Paul McGuire ptmcg at austin.rr.com
Mon Mar 24 23:22:35 EDT 2008


On Mar 24, 7:56 pm, Tess <test... at gmail.com> 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 elements where the following is true:
<p align="left"> and <div align="center">."

Wont this solution give you false hits, such as <p align="center"> and
<div align="left"> ?

-- Paul



More information about the Python-list mailing list