I need to check whether a page is being redirected or not without actually downloading the content. I just need the final URL. What’s the best way of doing this is Python? Thanks!
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you specifically want to avoid downloading the content, you’ll need to use the HEAD request method. I believe the
urllibandurllib2libraries do not support HEAD requests, so you’ll have to use the lower-levelhttpliblibrary: