I want to extract the content of all the HTML style tags using regular expression but the content doesn’t display.
import re
html = '<style type="text/css">h1{color:blue;}p{color:red;}</style><h1>Hi</h1><p>test <span class="time">test</span></p>'
tags = re.findall(r'<[^>]+>', html)
for a in tags:
content=re.findall(r'<style>(.*?)</style>',a)
print(content)
Hello! I never used regular expressions (I’m still a newbie in Python) but I share a possible solution that came to my mind, it’s simple but it solves your problem.