View Single Post
Old 10-08-2011, 06:27 AM   #1
MrJuggles
Junior Member
MrJuggles began at the beginning.
 
MrJuggles's Avatar
 
Posts: 1
Karma: 10
Join Date: Oct 2011
Location: North Wales, UK
Device: Kindle keyboard
A beginners question

Hey everyone
I'm super new to this and have been tinkering around with a few recipes to get articles from publications like Guardian, New Statesman and SFX (so far) It's working out good as I'm only doing the basic stuff. I just wanted to ask a quick question about the code below.
Do I just copy and paste it into my recipes or do I need to change or be aware of.

Quote:
Originally Posted by kiklop74 View Post
Small piece of code to convert all links to text:

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

Last edited by MrJuggles; 10-08-2011 at 06:32 AM. Reason: change thread subscription to instant
MrJuggles is offline   Reply With Quote