urllib.urlparse Bkz
Örnek kod:
from urlparse import urlparse
o = urlparse('http://url.something.com/bla.html?querystring=stuff')
url_without_query_string = o.scheme + "://" + o.netloc + o.path
Örnek çıktı: w3lib.url
modülünde bir fonksiyonu url_query_cleaner
vardır
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from urlparse import urlparse
>>> o = urlparse('http://url.something.com/bla.html?querystring=stuff')
>>> url_without_query_string = o.scheme + "://" + o.netloc + o.path
>>> print url_without_query_string
http://url.something.com/bla.html
>>>
Bu şudur: 'urllib.parse urlparse'den import? –
@RyanCady yes urllib.parse urlparse'dan ithalat için benim için çalıştı. – nipunasudha