我尝试使用beautifulsoap读取html标记,并检查是否有一些标记可用或丢失。在
我正在使用beauthoulsoup读取文件,然后在我的测试文件中使用它。在
在这里,我尝试了但没有成功:
class Testing(unittest.TestCase):
@classmethod
def setUp(name):
name.html = None
with open("index.html") as frd:
name.html = frd.read()
name.soup = BeautifulSoup(name.html)
if not name.html:
raise Exception('cant read')
def testing(self)
assert self.soup.find('html') == 'html'
#Raise : error
我在soup中找不到使用find()函数的html标记(尝试打印它以查看输出,但力不从心)。如果HTML文件中缺少HTML标记,如何引发异常?在
当你使用find时试试这个,它会返回美化的字符串或者没有!所以,这件事我可以建议!在
相关问题 更多 >
编程相关推荐