I need to read the current url with the query string which i used ?
Means i need to get the browser current address bar url..
A urllib2.Request
object provides a geturl()
method, which returns the full URL of a request. You may then pass it to urlparse.urlparse()
, which splits a URL into six components of every URL. Then you may access the query part via query
attribute.
An example:
>>> from urllib2 import urlopen
>>> from 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'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With