Ad
Code
Diff
  • import re
    
    def domain_name(url):
        res = re.search(r"(?:(//www\.|//|(?!//)www\.|maps\.))(?P<reqResult>.+?)(?:\.)", url)
        
        return res.group(2)
    • import re
    • def domain_name(url):
    • outers = [
    • "https://",
    • "http://",
    • "www.",
    • "maps.",
    • ]
    • for prefix in outers:
    • if url.startswith(prefix):
    • url = url[len(prefix):]
    • return url.split('.')[0]
    • res = re.search(r"(?:(//www\.|//|(?!//)www\.|maps\.))(?P<reqResult>.+?)(?:\.)", url)
    • return res.group(2)