Public Function GetResponse(ByVal StrURL As String) As String
Dim strReturn As String = ""
Dim objRequest As HttpWebRequest = Nothing
Dim ar As IAsyncResult = Nothing
Dim objResponse As HttpWebResponse = Nothing
Dim objs As StreamReader = Nothing
Try
objRequest = DirectCast(WebRequest.Create(StrURL), HttpWebRequest)
ar = objRequest.BeginGetResponse(New AsyncCallback(AddressOf GetScrapingResponse), objRequest)
'Wait for request to complete
ar.AsyncWaitHandle.WaitOne(1000 * 60, True)
If objRequest.HaveResponse = False Then
Throw New Exception("No Response!!!")
End If
objResponse = DirectCast(objRequest.EndGetResponse(ar), HttpWebResponse)
objs = New StreamReader(objResponse.GetResponseStream())
strReturn = objs.ReadToEnd()
Catch exp As Exception
Throw exp
Finally
If objResponse IsNot Nothing Then
objResponse.Close()
End If
objRequest = Nothing
ar = Nothing
objResponse = Nothing
objs = Nothing
End Try
Return strReturn
End Function