I've got a page scraper running----however, i run the pages to scrape from a database, and the scraping works for the first two lookups (one to login and get the auth cookie, and the second to scrape the particular page).
However, from the third try on, my httpwebrequest times out. I assume there's something not being closed, but I am really not sure.
here's my code
obviously I'm just returning a string----but this function is called on every iteration through my loop.
However, from the third try on, my httpwebrequest times out. I assume there's something not being closed, but I am really not sure.
here's my code
Visual Basic:
Function GetRequestStream(ByVal sURL As String) As String
Dim objRequest As HttpWebRequest = WebRequest.Create(sURL)
Dim objResponse As HttpWebResponse
Dim myWriter As StreamWriter
Dim sr As StreamReader
Dim objCookie As CookieContainer
Dim strRead As String
With objRequest
.Method = "PROPFIND"
.CookieContainer = Me.ckCont
Try
myWriter = New StreamWriter(.GetRequestStream())
Catch ex As Exception
RaiseEvent ErrorMessage(ex)
Return Nothing
End Try
End With
Try
objResponse = objRequest.GetResponse()
sr = New StreamReader(objResponse.GetResponseStream())
strRead = sr.ReadToEnd()
sr.Close()
objResponse.Close()
Return strRead
Catch ex As Exception
RaiseEvent ErrorMessage(ex)
Return Nothing
End Try
End Function