簡體   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

我有這個問題的相同問題: Python requests.get failed with 403 forbidden, even after using headers and Session object

不幸的是沒有答案。那么我該如何解決禁止的 403 問題?

我試過:

Python 請求 - 403 禁止 - 盡管設置了“User-Agent”標頭

和 :

Python 請求。 403 禁地

有人知道解決它的另一種選擇嗎?

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)

對於遇到同樣問題的人,解決我的問題的方法是在標題中填寫炊具信息。

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':" ..."}

您可以使用與 useg-agent 相同的方式獲取 cookie 信息,如此處所述

Python 請求。 403 禁地

嘗試 HTTP 代理,例如“Zyte”

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM