Trying to write beautifulsoup result to a file and get error message

MRAB python at mrabarnett.plus.com
Sun Nov 13 18:31:52 EST 2011


On 13/11/2011 22:37, goldtech wrote:
> If I try:
> ...
> soup = BeautifulSoup(ft3)
> f = open(r'c:\NewFolder\clean4.html', "w")
> f.write(soup)
> f.close()
>
> I get error message:
>
> Traceback (most recent call last):
>    File "C:\Documents and Settings\user01\Desktop\py\tb1a.py", line
> 203, in<module>
>      f.write(soup)
> TypeError: expected a character buffer object
>
> I want to write beautiful soup's result to a file, I am doing
> something wrong. Help appreciated.
>
What do you mean by "beautiful soup's result"?

The original HTML is text, and you want it to write some text to the
file, but what exactly are you expecting it to write?



More information about the Python-list mailing list