I want to get the url redirection log using Mechanize written in Python. For example, www.google.com --> www.google.co.in. The exact question has been asked before in SO but it is for Ruby
How to get redirect log in Mechanize?
The answer explains that to do this one can do the following in Ruby -
for m.redirection_limit in 0..99
begin
m.get(url)
break
rescue WWW::Mechanize::RedirectLimitReachedError
# code here could get control at
# intermediate redirection levels
end
end
I want to do the same using Python. Any help? What is the alternate of get(url) in Python for Mechanize?