pythonweb-scrapingbeautifulsoupscraperwiki

What is wrong with the bs4 documentation? I can't run unwrap() sample code


I'm trying to strip out some fussy text from pages like this. I want to preserve the anchored links but lose the breaks and the a.intro. I thought I could use something like unwrap() to strip off layers but I'm getting an error: TypeError: 'NoneType' object is not callable

For kicks, I tried running the documentation sample code itself, since I couldn't see how my version differed.

markup = '<a href="http://example.com/">I linked to <i>example.com</i></a>'
soup = BeautifulSoup(markup)
a_tag = soup.a

a_tag.i.unwrap()
a_tag
# <a href="http://example.com/">I linked to example.com</a>

I'm getting the exact same error. What am I missing here? I'm working in Scraperwiki, fwiw.


Solution

  • Seems to be a scraperwiki issue. Works fine in ipython console.