我正在发出 GET 请求来获取 JSON,它在任何设备上的任何浏览器中都可以正常工作,但不能通过 python 请求:
url = 'https://angel.co/autocomplete/new_tags'
params = {'query': 'sci', 'tag_type': 'MarketTag'}
resp = requests.get(url,params=params)
resp.raise_for_status()
gives HTTPError: 403 Client Error: Forbidden for url: https://angel.co/autocomplete/new_tags?query=ab&tag_type=MarketTag
所以我尝试:
-
Python 请求。 403 禁忌 https://stackoverflow.com/questions/38489386/python-requests-403-forbidden- 我不仅尝试在标头中使用 User-Agent,还尝试在中找到的所有其他标头
Request Headers
Firefox 中的 JSON 响应部分,但仍然是 403!
-
Python 请求 - 403 禁止 - 尽管设置了“User-Agent”标头 https://stackoverflow.com/questions/45086383/python-requests-403-forbidden-despite-setting-user-agent-headers- 通过 Session 对象发出请求,我仍然得到 403!
可能的原因是什么?还有其他我可以尝试使用的东西吗?
编辑:我使用的请求标头(在 firefox 中检查 JSON 的标头部分)headers
属性:
{'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'en-US,en;q=0.5',
'Connection': 'keep-alive',
'Host': 'angel.co',
'If-None-Match: 'W/"5857a9eac987138be074e7bdd4537df8"',
'TE': 'Trailers',
'Upgrade-Insecure-Requests': 1,
'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0'}