擅长:python、mysql、java
<p>使用标准库模块<a href="https://docs.python.org/2/library/urlparse.html#urlparse.urlparse" rel="nofollow">^{<cd1>}</a>:</p>
<pre><code>In [72]: from urlparse import urlparse
In [73]: flipkart = urlparse("http://www.flipkart.com/lenovo-a6000/p/itme3763q9phgbpn?q=Lenovo A6000&as=on&as- show=on&otracker=start&as-pos=p_1_lenovo&pid=MOBE3762KWZZYZHZ")
In [74]: flipkart.netloc
Out[74]: 'www.flipkart.com'
In [75]: flipkart
Out[75]: ParseResult(scheme='http', netloc='www.flipkart.com', path='/lenovo-a6000/p/itme3763q9phgbpn', params='', query='q=Lenovo A6000&as=on&as- show=on&otracker=start&as-pos=p_1_lenovo&pid=MOBE3762KWZZYZHZ', fragment='')
</code></pre>
<p>这将返回一个由6个组件组成的元组;对应于URL的一般结构:<code>scheme://netloc/path;parameters?query#fragment</code></p>