简体   繁体   English

如何在python中使用wget.download()下载文件并使用用户名和密码进行身份验证

[英]How to download a file using wget.download() in python and authenticating with username and password

Unable to download a file from a url using wget in python since the website requires a username and password 由于网站需要用户名和密码,因此无法使用python中的wget从URL下载文件

I've already tried: 我已经尝试过:

import wget

path = /path

url = "https://username:password@website.com"

wget.download(url, path)

If I don't include the username and password and simply the url, I end up with an "HTTP:401 Error Unauthorized". 如果我不包括用户名和密码,而仅包括URL,那么我将收到“ HTTP:401未经授权的错误”。 If I follow the code above inputting my username and password I get an "Invalid Url" 如果我按照上面的代码输入用户名和密码,则会收到“无效的网址”

无法对此发表评论,因为它可以作为答案:尝试使用python 请求 ,我知道该库支持认证,但是我以前从未使用过。

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

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