To expand on @johnsyweb's answer, here's an example of how to inline a small python script in bash to parse a URL:
URL="https://stackoverflow.com/questions/6174220/parse-url-in-shell-script"
HOST=$(URL=$URL python - <<EOF
import os
from urllib.parse import urlparse
uri = os.environ["URL"]
result = urlparse(uri)
host = result.netloc.split('@')[-1]
print(host)
EOF
)
$ echo $HOST
stackoverflow.com