You are viewing a single comment's thread. Return to all comments →
import re res = [] tag_attr = {} for _ in range(int(input())): element = input() tags = re.findall(r"(?<=\<)\w+", element) for tag in tags: if (attrs := re.search(fr"<\b{tag}\b([^>]+)>", element)) is not None: each_attr = re.findall(r"((?<=\s)\w+)=", attrs.group()) tag_attr[tag] = list(set(each_attr + tag_attr.get(tag, []))) else: tag_attr[tag] = list(set([""] + tag_attr.get(tag, []))) [res.append(f"{tag}:{','.join(sorted(attr))}") for tag, attr in tag_attr.items()] print(*sorted(res), sep="\n")
Seems like cookies are disabled on this browser, please enable them to open this website
Detect HTML Attributes
You are viewing a single comment's thread. Return to all comments →