如何通过python 3.0中的授权在http上下载文件,解决bug?

如何通过python 3.0中的授权在http上下载文件,解决bug?,第1张

如何通过python 3.0中的授权在http上下载文件,解决bug?

直接来自Py3k文档:http
://docs.python.org/dev/py3k/library/urllib.request.html#examples

import urllib.request# Create an OpenerDirector with support for Basic HTTP Authentication...auth_handler = urllib.request.HTTPBasicAuthHandler()auth_handler.add_password(realm='PDQ Application',    uri='https://mahler:8092/site-updates.py',    user='klem',    passwd='kadidd!ehopper')opener = urllib.request.build_opener(auth_handler)# ...and install it globally so it can be used with urlopen.urllib.request.install_opener(opener)urllib.request.urlopen('http://www.example.com/login.html')


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5663026.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-16
下一篇2022-12-16

发表评论

登录后才能评论

评论列表(0条)

    保存