如何解决如何在Python中使用带有defaultCredentials的request.get?
我正在使用以下代码使用VB.NET从URL获取html
Dim strURL As String = "https://abcdef.com/page.aspx"
Dim strOutput As String = ""
Dim wrResponse As WebResponse
Dim wrRequest As WebRequest = HttpWebRequest.Create(strURL)
wrRequest.UseDefaultCredentials = True
wrResponse = wrRequest.GetResponse()
我想在Python中实现相同的功能:
import requests
x = requests.get('https://abcdef.com/page.aspx',verify=False)
print(x.text)
但是我得到这个答复:
<h2>401 - Unauthorized: Access is denied due to invalid credentials.</h2>
<h3>You do not have permission to view this directory or page using the credentials that you supplied.
</h3>
这不起作用,因为该站点需要凭据。如何在请求中包含默认凭据?在我所看到的所有解决方案中,人们都在对用户名和密码进行硬编码。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。