Detect the Domain Name

  • + 0 comments

    Python 3

    import re, sys
    n = int(input())
    html = sys.stdin.read()
    pattern = r'https?://(www\.|ww2\.)?([a-z0-9\-]+\.[\.a-z0-9\-]+)'
    
    matches = re.findall(pattern, html)
    st = set()
    for match in matches:
        st.add(match[1])
    print(";".join(sorted(list(st))))