File size: 378 Bytes
b7a1a13
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from urllib.parse import urlparse
import validators

def valid_url(url):
    try:
        parsed_url = urlparse(url)
        # Check if scheme is missing and prepend 'https://' if so
        if not parsed_url.scheme:
            url = 'https://' + url
        # Validate the modified or original URL
        return validators.url(url), url
    except:
        return False, url