View Single Post
Old 12-22-2016, 05:39 AM   #18
slowsmile
Witchman
slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.slowsmile ought to be getting tired of karma fortunes by now.
 
Posts: 628
Karma: 788808
Join Date: May 2013
Location: Philippines
Device: Android S5
Here's another interesting BeautifulSoup snippet that I've just successfully used:

Code:
   # convert all html text to block text format        
    for tag in soup.findAll('p'):
        if tag.has_attr('style') and 'text-align: center' not in tag['style'].lower():
            del tag['style']
            tag['class'] = 'BlockText'
The above four lines of code will delete all 'style' attributes in p tags and then add the BlockText class - centered text will not be affected.
slowsmile is offline   Reply With Quote