1

I am using the below code to get html from a URL using VB.NET

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()

I wanted to implement the same functionality in Python :

import requests
x = requests.get('https://abcdef.com/page.aspx',verify=False)
print(x.text)

But I get this reponse:

  <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>

This is not working, since the site needs credentials. How can I include my default credentials in tht request? In all the solutions i have seen, people are hardcoding the username and password.

anandhu
  • 686
  • 2
  • 13
  • 40

0 Answers0