python - 如何在 python 中使用 request.get() 和 defaultCredentials?
问题描述
我正在使用下面的代码使用 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>
这不起作用,因为该站点需要凭据。如何在请求中包含我的默认凭据?在我见过的所有解决方案中,人们都在硬编码用户名和密码。
解决方案
推荐阅读
- javascript - 检查 vue-multiselect 下拉菜单
- swift - 使用 swift, sum 和 Difference 进行数小时运算
- sql - 字段列表中的列 '' 不明确。(加入时)
- azure - 在 Azure Front Door 中使用用户代理阻止 SQL 注入尝试的最佳方法是什么?
- css - React Bootstrap 轮播图像作为背景
- android - 如何在 NativeScript for android 中复制 MainActivity.class
- javascript - 只接受小于 1920x1080 的照片
- deep-learning - 带有for循环的AttentionBlock导出大图?
- python - 根据单独数据框中的单词匹配创建列 - 有效但速度很慢
- linux - grep : 对以特定字母结尾或开头的字符串进行排序