Setting the title tag attribute of a title tag clears the string attribute of another tag in BeautifulSoup

I am trying to change the title tags of some html documents using BeautifulSoup with the following code:

>>> doc = BeautifulSoup(open(filename))
>>> root = doc.find('html') # works only with html parser
>>> hafta = root.find(id="hafta")
>>> content = hafta.find('div', {'class':'convHtml'})
>>> content.find('b').string
u'BAKANLARA N\u0130\xc7\u0130N KURBAN KES\u0130L\u0130R?'
>>> doc.title.string = content.find('b').string
>>> content.find('b').string
>>>  

Oddly enough, the operator doc.title.string = content.find('b').stringclears the line inside content.find('b'). Why is this happening?

+3
source share
1 answer

This is a mistake in Beautiful Soup . I made a fix to be released in the next version.

+3
source

All Articles