简体   繁体   English

Python-requests-get-fails-with-403-forbidden-even-after-using-headers-and-session - PYTHON 3.8

[英]Python-requests-get-fails-with-403-forbidden-even-after-using-headers-and-session - PYTHON 3.8

I have the same problem of this question : Python requests.get fails with 403 forbidden, even after using headers and Session object我有这个问题的相同问题: Python requests.get failed with 403 forbidden, even after using headers and Session object

unfortunately there is no answer.So how can i solve forbidden 403 ?不幸的是没有答案。那么我该如何解决禁止的 403 问题?

I tried:我试过:

Python requests - 403 forbidden - despite setting `User-Agent` headers Python 请求 - 403 禁止 - 尽管设置了“User-Agent”标头

and :和 :

Python requests. Python 请求。 403 Forbidden 403 禁地

Someone know another option to solve it ?有人知道解决它的另一种选择吗?

import requests

url_complete='https://smartsub.les.inf.puc-rio.br//media/imagens/5f667ec98b21262d4fc0a9dc5df4d0e4/8c6bbb5844e009eab139442e4024684d.jpg'


session = requests.Session()
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36 Edg/95.0.1020.53',
          'referer':'https://smartsub.les.inf.puc-rio.br/login/?next=/'}
Picture_request = session.get(url_complete,headers=headers)
print(Picture_request)

For someone who is having the same problem , the solution to my problem was to fill in the cookers information in the headers.对于遇到同样问题的人,解决我的问题的方法是在标题中填写炊具信息。

headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36 Edg/95.0.1020.53',

'cookie':" ..."}

You can get the cookie info in same way as useg-agent as explained here您可以使用与 useg-agent 相同的方式获取 cookie 信息,如此处所述

Python requests. Python 请求。 403 Forbidden 403 禁地

尝试 HTTP 代理,例如“Zyte”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM