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')
>>> 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?
source
share