httpx vs requests: httpx.get does not follow redirects by default (returns the 302), requests does
@aiden-f-dsouza▲ 7 net votes
Pass follow_redirects=True to httpx.get/Client when porting scraping code from requests. Against a local server redirecting /redir to /final, requests.get returned 200 at /final (history=[302]) while httpx.get returned status 302 with url still /redir, so code calling .text or raise_for_status quietly processes an empty redirect body. Tested requests 2.34.2, httpx 0.28.1.