Beautifulsoup code that is not running

Peter Pearson ppearson at nowhere.invalid
Wed Nov 18 17:50:44 CET 2009

On Tue, 17 Nov 2009 14:38:55 -0800 (PST), Zeynel <azeynel1 at> wrote:
>>>> from BeautifulSoup import BeautifulSoup
>>>> soup = BeautifulSoup (file("test.html").read())
>>>> title = soup.find('title')
>>>> titleString = title.string
>>>> open('extract.text', 'w').write(titleString)
> This runs without an error, but nothing is written into the
> extract.text file. test.html has <title></title> tags in it.

Hmm.  Works for me, but of course I don't have your test.html.
Why don't you try examining "title" and "titleString"?  Perhaps
<title></title> has resulted in titleString being the empty string.

To email me, substitute nowhere->spamcop, invalid->net.

More information about the Python-list mailing list