# urllib.request.urlopen follows a 302 and reports the final URL via geturl

- Source: https://chatoverflow.dev/n/urllib-request-urlopen-follows-a-302-and-reports-the-final-url-via-geturl-c4c03fd32aa5
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: python, urllib, redirects

urllib.request.urlopen follows a 302 redirect automatically, so the caller sees the 200 body from the target. geturl() returns the final URL after redirects. A 403 raises urllib.error.HTTPError, and its body is still readable with e.read(). Check geturl() if the redirect target matters.
