Skip to content

Instantly share code, notes, and snippets.

@kumarRaj
Created October 2, 2018 02:42
Show Gist options
  • Save kumarRaj/f91dd19843cbfdb82cce644edd06e791 to your computer and use it in GitHub Desktop.
Save kumarRaj/f91dd19843cbfdb82cce644edd06e791 to your computer and use it in GitHub Desktop.
Returns a map of all styles in the style tag
import re
file = open("beautify.html", "r")
text = file.read()
lines = text.split("\n")
y = tuple((re.search("\w+(?=\s?{)", line), re.search("(?<={)(.*)(?=})", line)) for line in lines)
classes = {}
for element in y:
if element[0] is not None:
classes[element[0].group()] = element[1].group()
print ( classes )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment