How to get the (current url + query string) using python code with urllib2? -
i need read current url query string used ?
means need browser current address bar url..
a urllib2.request
object provides geturl()
method, returns full url of request. may pass urlparse.urlparse()
, splits url 6 components of every url. may access query part via query
attribute.
an example:
>>> urllib2 import urlopen >>> urlparse import urlparse >>> req = urlopen('http://capitalfm.com/?foo=bar') >>> req.geturl() 'http://www.capitalfm.com/?foo=bar' >>> url = urlparse(req.geturl()) >>> url.query 'foo=bar'
Comments
Post a Comment