View Single Post
Old 06-04-2011, 07:49 PM   #1
BRGriff
Connoisseur
BRGriff began at the beginning.
 
Posts: 58
Karma: 12
Join Date: May 2011
Location: Deland, Florida
Device: Kindle 3
Remove "alink", not just change it to text

I found code on this forum written by Starson17 which allows for the changing of an "alink" to a text object. The code works fine and once converted to a text object, I can manipulate it with extra css to diminish the text's size and therefore accomplish part of what I want: to maximize the available screen area for viewing an image.

Starson17's code is:

Code:
    def preprocess_html(self, soup):
        for alink in soup.findAll('a'):
            if alink.string is not None:
               tstr = alink.string
               alink.replaceWith(tstr)
        return soup
My question is this: Once I have found the "alink" tag, as is done by Starson17's code, how can I "remove" it instead of "replacing" it with a string?

Seems to me if I could define the "tstr" as a null item, there would no longer be an "alink". I tried "tstr = []" but that did not work! Any other suggestions?

Any help would be greatly appreciated.
BRGriff is offline   Reply With Quote