View Single Post
Old 01-05-2019, 08:03 AM   #1
jma1
Connoisseur
jma1 began at the beginning.
 
Posts: 85
Karma: 10
Join Date: Dec 2015
Device: Kindle
Convert links to text in downloaded news

Downloaded news feeds can contain many hyperlinks to web pages which exist in the RSS articles. Using my kindle I can't stop inadvertently pressing text with embedded links and jumping to web pages when I only want to page forward in the document.

Is there a recipe command that would convert all the web hyperlinks to 'flat' text, i.e. the text with underscoring still appears with the article but there is no underlying link to a web page.

I did try this code found in a sticky recipe post but it does not kill the links.

Spoiler:
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

Thanks in advance.
jma1 is offline   Reply With Quote