Nelson78
Well-known Member
- Joined
- Sep 11, 2017
- Messages
- 526
- Office Version
- 2007
Hello everybody.
I'm a newbie by surfing the net via GET and POST request.
So far, I've had no many problems in scraping data from a link.
Now, the following step is managing a barrier in terms of authentication.
In this link I have the form to insert login and password:
Then, if the operation is successful, I'm redirected to the desired link:
How can I face this issue?
I know I have to set a POST request to send the credentials. I also have Fiddler on my pc to parse cookies.
Anyway, my first doubt is: do I have to build the POST request referring to the link where the login form is set, or referring to the following page where I'm redirected?
I mean, something like this?
Thank's in advance for your tips.
I'm a newbie by surfing the net via GET and POST request.
So far, I've had no many problems in scraping data from a link.
Code:
Sub getintoSITE()
Dim URL As String, strResponse As String
Dim objHTTP As Object
URL = "............"
Set objHTTP = CreateObject("MSXML2.XMLHTTP")
With objHTTP
.Open "GET", URL, False
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.send
strResponse = .responseText
Sheets(3).Range("A1") = strResponse
End With
End Sub
Now, the following step is managing a barrier in terms of authentication.
In this link I have the form to insert login and password:
Code:
https://xxxxx/xxxxx/xxxxx/login.aspx
Then, if the operation is successful, I'm redirected to the desired link:
Code:
https://xxxxx/xxxxx/yyyyy.aspx
How can I face this issue?
I know I have to set a POST request to send the credentials. I also have Fiddler on my pc to parse cookies.
Anyway, my first doubt is: do I have to build the POST request referring to the link where the login form is set, or referring to the following page where I'm redirected?
I mean, something like this?
Code:
Sub getintoSITE()
Dim URL As String, strResponse As String
Dim objHTTP As Object
URL_login = "https://xxxxx/xxxxx/xxxxx/login.aspx"
URL_goal = "https://xxxxx/xxxxx/yyyyy.aspx"
With CreateObject(“MSXML2.XMLHTTP”)
.Open “post”, URL_login, False
.setRequestHeader “Content-type”, “application/x-www-form-urlencoded”
...............................
Thank's in advance for your tips.
Last edited: