I have a huge number of urls or domains and I want to determine whether they perform a redirect to a different domain.
When I check for status code 302, I can figure out which ones do a redirect. However, some of them just perform a redirect from somedomain.com to somedomain.com/somename.php, whereas the ones I need are those that do a redirect from somedomain.com to otherdomain.com.
I'm working with Python and the requests library and I have a somewhat limited knowledge when it comes to programming languages. If you have an idea that specifically requires me to use a different language, I suppose I can figure it out.
If you are using
python-requests, you can userequest.historyto get all redirections, except the final hop, which in turn will be available inrequest.url. For example:If there is no redirection, then
request.historywill be an empty list.