I am trying to redirect one page to another by using mitmproxy and Python. I can run my inline script together with mitmproxy without issues, but I am stuck when it comes to changing the URL to another URL. Like if I went to google.com it would redirect to stackoverflow.com
def response(context, flow):
print("DEBUG")
if flow.request.url.startswith("http://google.com/"):
print("It does contain it")
flow.request.url = "http://stackoverflow/"
This should in theory work. I see http://google.com/
in the GUI of mitmproxy (as GET) but the print("It does contain it")
never gets fired.
When I try to just put flow.request.url = "http://stackoverflow.com"
right under the print("DEBUG")
it won't work neither.
What am I doing wrong? I have also tried if "google.com" in flow.request.url
to check if the URL contains google.com
but that won't work either.
Thanks
http://
or is ithttps://
? – Kikeliatail -f
on, since mitmproxy's GUI fills the whole terminal). It ishttp://
and I have carefully copy-pasted the entire URL from the mitmproxy GUI, so it matches 100%. Obviously google.com and stackoverflow.com are just fillers. – Hulk