0

I have the same problem of this question : Python requests.get fails with 403 forbidden, even after using headers and Session object

unfortunately there is no answer.So how can i solve forbidden 403 ?

I tried:

Python requests - 403 forbidden - despite setting `User-Agent` headers

and :

Python requests. 403 Forbidden

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)
Vitor Bento
  • 384
  • 4
  • 17

2 Answers2

1

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

Python requests. 403 Forbidden

Vitor Bento
  • 384
  • 4
  • 17
0

Try an HTTP proxy, for instance 'Zyte'

ish
  • 75
  • 5
  • Thanks for the reply, but I didn't understand. Could you be a little more specific? What do I need to change exactly? – Vitor Bento Nov 16 '21 at 16:04
  • You need to implement a proxy solution in your GET request. Check this link: https://www.zyte.com/smart-proxy-manager/ – ish Nov 16 '21 at 16:33