python 获取url的host

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/cugb1004101218/article/details/46501461
    import urllib

    protocol, s1 = urllib.splittype('http://www.freedom.com:8001/img/people')
    # ('http', '//www.freedom.com:8001/img/people')

    host, s2=  urllib.splithost(s1)
    # ('www.freedom.com:8001', '/img/people')
    
    host, port = urllib.splitport(host)
    # ('www.freedom.com', '8001')

阅读更多

没有更多推荐了,返回首页