Thursday, 15 April 2010

python - Can I combine two 'findAll' search blocks in beautifulsoup, into one? -


Can I combine these two blocks into one:

EDIT: Loops like Yacoby No other method was in response to the combination of. Soup.find all (['script', 'form'] for tags in

  tag: tag.extract () for tag in soup.find all (id = "footer") : Tag.extract ()  

In addition to this, I can do several blocks from one:

soup.findle (id = "footer" ): Tags for tags in Soup.findAll (id = "content"). Extract (): tags for tags in soup.find all (id = "links") .extract (): tag.extract () < / Code>

or there may be some lambda expressions, where I can check in the array or in some other simpler method

In addition to how can I get the tag with the attribute class, as is the class reserved keyword:

Edit: This part is solved by soup. Attrs = {'class': 'noprint'}):

  for tag in soup.findAll (class = "noprint"): tag. Extract ()  

Yo You [