M
MARTIN LANNY
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(ByVal 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 objStreamReceive As System.IO.Stream
Dim objEncoding As System.Text.Encoding
Dim objStreamRead As System.IO.StreamReader
Try
' Setup our Web request
objRequest = Net.WebRequest.Create(URL)
objRequest.Timeout = TimeoutSeconds * 1000
' Retrieve data from request
objResponse = objRequest.GetResponse
objStreamReceive = objResponse.GetResponseStream
objEncoding = System.Text.Encoding.GetEncoding("utf-8")
objStreamRead = New
System.IO.StreamReader(objStreamReceive, objEncoding)
' Set function return value
GetPageHTML = objStreamRead.ReadToEnd()
' Check if available, then close response
If Not objResponse Is Nothing Then
objResponse.Close()
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.Method = "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(ByVal 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 objStreamReceive As System.IO.Stream
Dim objEncoding As System.Text.Encoding
Dim objStreamRead As System.IO.StreamReader
Try
' Setup our Web request
objRequest = Net.WebRequest.Create(URL)
objRequest.Timeout = TimeoutSeconds * 1000
' Retrieve data from request
objResponse = objRequest.GetResponse
objStreamReceive = objResponse.GetResponseStream
objEncoding = System.Text.Encoding.GetEncoding("utf-8")
objStreamRead = New
System.IO.StreamReader(objStreamReceive, objEncoding)
' Set function return value
GetPageHTML = objStreamRead.ReadToEnd()
' Check if available, then close response
If Not objResponse Is Nothing Then
objResponse.Close()
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.Method = "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