<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def url_protocol(url, port=None):
 """ Get the protocol to use for a URL. return 'http' or 'https' or None """

    if not url.startswith('http://') and not url.startswith('https://'):
        return None

    urlinfo = urllib2.urlparse.urlparse(url)
    assert urlinfo.scheme in ['http', 'https'], 'Invalid URL scheme in {}'.format(url)
    return urlinfo.scheme