admin管理员组

文章数量:1345070

This code work: (Native python urllib)

from urllib.request import Request, urlopen

req = Request(url='/', headers={'User-Agent': 'Mozilla/5.0'})
status_code = urlopen(req).getcode()
print(status_code) # 200

And this not: (Modern httpx)

import httpx

res = httpx.get('/', headers={'User-Agent': 'Mozilla/5.0'})
print(res.status_code) # 403

Also tried with all request headers from browser, result status code 403

How to get response with httpx?

本文标签: pythonHTTPX response 403Stack Overflow