Sort by

recency

|

170 Discussions

|

  • + 0 comments
    class MyHTMLParser(HTMLParser):
            
        def handle_starttag(self, tag, attrs):
            print("Start :", tag)
            [print('->', nm, '>', value) for nm, value in attrs]
    
        def handle_endtag(self, tag):
            print("End   :", tag)
            
        def handle_startendtag(self, tag, attrs):
            print("Empty :", tag)
            [print('->', nm, '>', value) for nm, value in attrs]
    
        def handle_comment(self, data):
            pass
    
  • + 0 comments

    from html.parser import HTMLParser

    class MyHTMLParser(HTMLParser): def handle_starttag(self, tag, attrs): print("Start :", tag) for attr in attrs: print("->", attr[0], ">", attr[1])

    def handle_endtag(self, tag):
        print("End   :", tag)
    
    def handle_startendtag(self, tag, attrs):
        print("Empty :", tag)
        for attr in attrs:
            print("->", attr[0], ">", attr[1])
    

    parser = MyHTMLParser()

    for i in range(int(input())): parser.feed(input())

  • + 0 comments
    from html.parser import HTMLParser
    
    class MyHTMLParser(HTMLParser):
        def handle_starttag(self, tag, attrs):
            print("Start :", tag)
            for attr in attrs:
                print("->", attr[0], ">", attr[1])
    
        def handle_endtag(self, tag):
            print("End   :", tag)
            
        def handle_startendtag(self, tag, attrs):
            print("Empty :", tag)
            for attr in attrs:
                print("->", attr[0], ">", attr[1])
    
    parser = MyHTMLParser()
    
    for i in range(int(input())):
        parser.feed(input())
    
  • + 0 comments
    from html.parser import HTMLParser
    class MyHTMLParser(HTMLParser):
        def handle_starttag(self, tag, attrs):
            print("Start".ljust(5), ":", tag)
            for n, v in attrs:
                print(f"-> {n} > {v}")
        def handle_endtag(self, tag):
            print("End".ljust(5), ":", tag)
        def handle_startendtag(self, tag, attrs):
            print("Empty".ljust(5), ":", tag)
            for n, v in attrs:
                print(f"-> {n} > {v}")
    t = ''.join(input() for _ in range(int(input())))
    parser = MyHTMLParser()
    parser.feed(t)
    
  • + 0 comments
    from html.parser import HTMLParser
    
    class MyHTMLParser(HTMLParser):
        def handle_starttag(self, tag, attrs):
            print ("Start :", tag)
            if attrs:
                for attr, value in attrs:
                    print(f"-> {attr} > {value}")
            
        def handle_endtag(self, tag):
            print ("End   :", tag)
        def handle_startendtag(self, tag, attrs):
            print(f"Empty : {tag}")
            if attrs:
                for attr, value in attrs:
                    print(f"-> {attr} > {value}")
            
    
    parser = MyHTMLParser()
    
    for i in range(int(input())):
        parser.feed(input())