import urlparse
#domain=
print urlparse.urlparse("http://www.google.com/search?q=fish").netloc


example2


from urlparse import urlsplit
parsed = urlsplit('http://user:pass@NetLoc:80/path;parameters/path2;parameters2?query=argument#fragment')
print parsed
print 'scheme :', parsed.scheme
print 'netloc :', parsed.netloc
print 'path :', parsed.path
print 'query :', parsed.query
print 'fragment:', parsed.fragment
print 'username:', parsed.username
print 'password:', parsed.password
print 'hostname:', parsed.hostname, '(netloc in lower case)'
print 'port :', parsed.port
arrow
arrow
    文章標籤
    python
    全站熱搜

    peicheng 發表在 痞客邦 留言(0) 人氣()