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

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -