最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - HTTPX response 403 - Stack Overflow

programmeradmin1浏览0评论

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?

发布评论

评论列表(0)

  1. 暂无评论