如何使用Python传递凭证https url

时间:2022-04-19 00:00:01

i want to download files from remote server I have https link, how to pass the credentials?

我想从远程服务器下载文件我有https链接,如何传递凭据?

url = 'https://test.com/download/'
f =urllib2.urlopen(url)
data = f.read()
print data 

when i run this code, i am not getting any error from interpreter, the script ends waiting for few seconds. i get the html body of browser which was expecting the credentials

当我运行此代码时,我没有从解释器获得任何错误,脚本结束等待几秒钟。我得到了浏览器的html主体,它正在期待凭据

2 个解决方案

#1


I'm not sure if this is what you need, but take a look at the requests package. The first example involves an https request.

我不确定这是否是您需要的,但请查看请求包。第一个示例涉及https请求。

#2


Why dont you call wget linux command in python script. It supports passing credentials. You can use subprocess module in python to execute wget cmd.

为什么不在python脚本中调用wget linux命令。它支持传递凭据。您可以在python中使用子进程模块来执行wget cmd。

#1


I'm not sure if this is what you need, but take a look at the requests package. The first example involves an https request.

我不确定这是否是您需要的,但请查看请求包。第一个示例涉及https请求。

#2


Why dont you call wget linux command in python script. It supports passing credentials. You can use subprocess module in python to execute wget cmd.

为什么不在python脚本中调用wget linux命令。它支持传递凭据。您可以在python中使用子进程模块来执行wget cmd。