Hi everyone,
I am having a real trouble to figure out how to amend this code to
switch from GET to POST method.
--------------------------------------------------------
Public Function GetPageHTML(ByV al URL As String, Optional ByVal
TimeoutSeconds As Integer = 10) As String
' Retrieves the HTML from the specified URL, using a default
timeout of 10 seconds
Dim objRequest As Net.WebRequest
Dim objResponse As Net.WebResponse
Dim objStreamReceiv e As System.IO.Strea m
Dim objEncoding As System.Text.Enc oding
Dim objStreamRead As System.IO.Strea mReader
Try
' Setup our Web request
objRequest = Net.WebRequest. Create(URL)
objRequest.Time out = TimeoutSeconds * 1000
' Retrieve data from request
objResponse = objRequest.GetR esponse
objStreamReceiv e = objResponse.Get ResponseStream
objEncoding = System.Text.Enc oding.GetEncodi ng("utf-8")
objStreamRead = New
System.IO.Strea mReader(objStre amReceive, objEncoding)
' Set function return value
GetPageHTML = objStreamRead.R eadToEnd()
' Check if available, then close response
If Not objResponse Is Nothing Then
objResponse.Clo se()
End If
Catch
' Error occured grabbing data, simply return nothing
Return ""
End Try
End Function
--------------------------------------------------------
This code gets the html source from any url you submit to it.
Can someone tell me what to do?
I tried to add this line:
objRequest.Meth od = "POST"
, right below the TRY, but nothing changed and I really don't know what
to do next, while all my customers are getting inpatient.
I am even willing to pay for the answer. THIS IS MY LAST RESOURCE.
Please let me know.
Martin
I am having a real trouble to figure out how to amend this code to
switch from GET to POST method.
--------------------------------------------------------
Public Function GetPageHTML(ByV al URL As String, Optional ByVal
TimeoutSeconds As Integer = 10) As String
' Retrieves the HTML from the specified URL, using a default
timeout of 10 seconds
Dim objRequest As Net.WebRequest
Dim objResponse As Net.WebResponse
Dim objStreamReceiv e As System.IO.Strea m
Dim objEncoding As System.Text.Enc oding
Dim objStreamRead As System.IO.Strea mReader
Try
' Setup our Web request
objRequest = Net.WebRequest. Create(URL)
objRequest.Time out = TimeoutSeconds * 1000
' Retrieve data from request
objResponse = objRequest.GetR esponse
objStreamReceiv e = objResponse.Get ResponseStream
objEncoding = System.Text.Enc oding.GetEncodi ng("utf-8")
objStreamRead = New
System.IO.Strea mReader(objStre amReceive, objEncoding)
' Set function return value
GetPageHTML = objStreamRead.R eadToEnd()
' Check if available, then close response
If Not objResponse Is Nothing Then
objResponse.Clo se()
End If
Catch
' Error occured grabbing data, simply return nothing
Return ""
End Try
End Function
--------------------------------------------------------
This code gets the html source from any url you submit to it.
Can someone tell me what to do?
I tried to add this line:
objRequest.Meth od = "POST"
, right below the TRY, but nothing changed and I really don't know what
to do next, while all my customers are getting inpatient.
I am even willing to pay for the answer. THIS IS MY LAST RESOURCE.
Please let me know.
Martin
Comment