Python beautifulsoup trying to remove html tags 'span'

Posted by Michelle Jun Lee on Stack Overflow See other posts from Stack Overflow or by Michelle Jun Lee
Published on 2010-03-27T16:19:23Z Indexed on 2010/03/27 16:23 UTC
Read the original article Hit count: 605

Filed under:
|
|
|

I am trying to remove

[<span class="street-address">
            510 E Airline Way
           </span>]

and I have used this clean function to remove the one that is in between < >

def clean(val):
 if type(val) is not StringType: val = str(val)
 val = re.sub(r'<.*?>', '',val) 
 val = re.sub("\s+" , " ", val)
 return val.strip()

and it produces [ 510 E Airline Way ]`

i am trying to add within "clean" function to remove the char '[' and ']' and basically i just want to get the "510 E Airline Way".

anyone has any clue what can i add to clean function?

thank you

© Stack Overflow or respective owner

Related posts about python

Related posts about remove