0
我不明白这个错误。如何让“内容”变得可写?BeautifulSoup类型错误
from bs4 import BeautifulSoup
soup = BeautifulSoup(open("http://www.asdf.fi/asdf.html"))
content = soup.find(id="content")
with open("test.html", "a") as myfile:
myfile.write(content)
错误:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
TypeError: expected a character buffer object
啊,好的谢谢。 BTW ... soup = BeautifulSoup(open(filename.read())) – Leke
不能,'.read()'不是'str'类的方法,它是'file'类的一个方法。 – 0605002