Python Can';无法从url获得正确的响应
我正在使用库“请求”从url(“”)获取图像,但响应错误,代码401。这是我的rtsp相机的url 我尝试使用“HTTPBasicAuth”、“HTTPDigestAuth”和“HTTPProxyAuth”。但它不起作用Python Can';无法从url获得正确的响应,python,python-requests,rtsp,Python,Python Requests,Rtsp,我正在使用库“请求”从url(“”)获取图像,但响应错误,代码401。这是我的rtsp相机的url 我尝试使用“HTTPBasicAuth”、“HTTPDigestAuth”和“HTTPProxyAuth”。但它不起作用 import requests from requests.auth import HTTPBasicAuth url = "http://any_login:any_password@10.10.9.2/ISAPI/Streaming/channels/101/pictur
import requests
from requests.auth import HTTPBasicAuth
url = "http://any_login:any_password@10.10.9.2/ISAPI/Streaming/channels/101/picture?snapShotImageType=JPEG"
response = requests.get(url, auth=requests.auth.HTTPBasicAuth("any_login", "any_password"))
if response.status_code == 200:
with open("sample.jpg", 'wb') as f:
f.write(response.content)
我期望从rtsp流输出图像文件,但我得到了错误代码401。
401
表示未经授权的请求。您是否提供了正确的凭据?链接是否有效(例如在您的浏览器中)?是的,我提供了正确的凭据。我可以从具有该凭据的浏览器中获取图像。此链接在其他浏览器中运行良好。请添加标题,然后重试