I wish to write the beautifulsoup form with this code:
soup = BeautifulSoup(con.content)
f = open('/*/*/Desktop/littletext.rtf','w')
f.write(str(soup))
f.close()
I get this error:
Traceback (most recent call last): File "///Desktop/test123.py", line 10, in f.write(soup) TypeError: must be str, not BeautifulSoup
Any ideas how to fix this? I tried to convert 'soup' to string but didn't work -- f.write(str(soup))
found out my problem is that I had to use 'wb' in
f = open('/*/*/Desktop/littletext.rtf','wb')
and
f.write(str(soup))
had to be
f.write(soup.encode('utf-8'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With