I'm trying to strip out particular chunks of HTML documents, particularly Javascript (<script></script>) and inline CSS (<style></style>). Currently I'm trying to use re.sub() but am not having any luck with Multiline. Any tips?
import re
s = '''<html>
<head>
<title>Some Template</title>
<script type="text/javascript" src="{path to Library}/base.js"></script>
<script type="text/javascript" src="something.js"></script>
<script type="text/javascript" src="simple.js"></script>
</head>
<body>
<script type="text/javascript">
// HelloWorld template
document.write(examples.simple.helloWorld());
</script>
</body>
</html>'''
print(re.sub('<script.*script>', '', s, count=0, flags=re.M))
BeautifulSoup?