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.