Python Requests: How to restrict redirects within the same domain?
02:59 26 May 2023
session = requests.Session()
session.max_redirects = max_red
response = session.get(ip_address)

How can I limit redirects to same domain only? I mean if the main requests was made to 192.168.1.1 then I want to allow redirections to 192.168.1.1, http://192.168.1.1, https://192.168.1.1, http://sub.192.168.1.1 etc...

I don't want to follow any external redirection, how can I do that in python?

python python-3.x http session python-requests