mechanize python XE #8
def redirect(self):
try:
if self.agent == True:
br = Browser()
UserAgent = "Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0"
header = {"User-Agent" : UserAgent}
br.set_handle_robots(False)
br.addheaders = [("User-agent", "Fifefox")]
remote_url = br.open(self.target).geturl()
else:
remote_url = u.urlopen(self.target).geturl()
return(remote_url)
except Exception as e:
print(e)