def url_http_to_https(value):
parts = urlparse(value)
if parts.scheme != 'http':
return value
# Check if the url contains ':80' and remove it if that is the case
netloc_parts = parts.netloc.rsplit(':', 1)
if len(netloc_parts) == 2 and netloc_parts[1] == '80':
netloc = netloc_parts[0]
else:
netloc = parts.netloc
return urlunparse(('https', netloc) + parts[2:])
评论列表
文章目录