Python open url with urllib than get back the changed url of opened webpage
<p>I want to send some requests to Google maps. I open the url that is changed based on the request. And I want to get back the changed url.
An example:</p>

<pre><code>import urllib, urllib2

my_address = '1600 Amphitheatre Parkway Mountain View, CA 94043'
data = urllib.urlencode({'output':'csv', 'q':my_address})
req = urllib2.Request('https://www.google.co.uk/maps/place?' + data)
res_0 = urllib2.urlopen(req)
print res_0.geturl()
</code></pre>

<p>url to open (<code>res_0.geturl()</code>):</p>

<p><code>'https://www.google.co.uk/maps/search/1600+Amphitheatre+Parkway+Mountain+View,+CA+94043/data=!4m2!2m1!4b1?dg=dbrw&amp;newdg=1'</code></p>

<p>And I want to get back the changed url, that is:</p>

<p><code>'https://www.google.co.uk/maps/place/1600+Amphitheatre+Pkwy,+Mountain+View,+CA+94043,+USA/@37.4223371,-122.0866079,17z/data=!3m1!4b1!4m5!3m4!1s0x808fba027820e5d9:0x60a90600ff6e7e6e!8m2!3d37.4223329!4d-122.0844192'</code></p>

<p>I opened the <code>res_0</code> url in the browser manually and I get the above changed url.</p>

<p>How can I do that?</p>

<p>Thank you!</p>

<p>you can use the .geturl() method inside urllib2</p>

<p>Example:</p>

<pre><code>print res_0.geturl()
</code></pre>

python url urllib2