Thanks for your reply. However, I am afraid that my understanding of
the BeautyfulSoup together with too little experience in html makes
that it does not work for me. My test fragment, based on a fragment of
a Google Scholar page, is:
paper = '<span class="a">author1, <b>author2</b>, author3 - Title of
paper, year - Publisher</span>'
soup = BeautifulSoup(''.join(paper))
for tag in soup.findAll('b'):
print tag.prettify()
tag.replaceWithChildren()
print tag.prettify()
print '-----'
This results in:
<b>
author2
</b>
Traceback (most recent call last):
File "testbeauty.py", line 18, in <module>
tag.replaceWithChildren()
TypeError: 'NoneType' object is not callable
If I delete the () of replaceWithChildren I get:
<b>
author2
</b>
<b>
author2
</b>
-----
This makes that soup.prettify() gives
<span class="a">
author1,
<b>
author2
</b>
, author3 - Title of paper, year - Publisher
</span>
and what I want is
<span class="a">
author1, author2, author3 - Title of paper, year - Publisher
</span>
How to achieve?
Cheers, Janwillem
On Nov 1, 8:16 am, Aaron DeVore <
aaron.dev...@gmail.com> wrote:
> Janwillem,
> My Beautiful Soup mod has a new method of Tag called
> replaceWithChildren. It does exactly what it sounds like; it removes
> an element from the tree and inserts its children where it was just
> at.
>
> for tag in soup.findAll"b"):
> tag.replaceWithChildren()
>
> The URL is:
http://github.com/adevore/old-beautiful-soup
>
> Cheers!
> Aaron DeVore
>