Quote:
Originally Posted by MondeoST24
Thanks,
Let me give you a bit more info. What I'm trying to achieve is an application which has seven web browsers each connecting to a pricing site. My application automatically goes through each site, logging in, choosing a vehicle, choosing parameters then finally scraping a price of the final page. In the end I want to return all the prices to the user cheapest first.
Is there a better way of going about it that someone can suggest?
Thank you
|
The
WebBrowser control is asynchronous by nature so there'd be no need to muck about with threads, but this is a ham-fisted brute force approach to the method and I think there is a better way.
Why do you need the web browser if all you are interested in is the HTML? There are several open discussions about using
HttpWebRequest to get the HTML of a page, then parsing that HTML for specific values on this site. I think this would be the best method, though the only catch is that I can't figure out how to get that HTML text into a class like
HtmlDocument that provides nice DOM parsing methods.
*edit* Actually I've made a breakthrough though it's kind of messy. The following code demonstrates retrieving a page's HTML, creating an mshtml object from it, then using the mshtml object's properties to get values from the HTML. It requires a reference to the
Microsoft.mshtml assembly:
Code:
Imports System.Net
Imports mshtml
Module Module1
Sub Main()
Dim requestUri As New Uri("http://www.xtremevbtalk.com")
Dim request As WebRequest
Dim response As WebResponse
' Make our request then get the response
request = WebRequest.Create(requestUri)
request.Method = "GET"
response = request.GetResponse()
' Get the page's HTML from the response
Dim responseStream As System.IO.Stream
Dim reader As System.IO.StreamReader
Dim theHtml As String
responseStream = response.GetResponseStream()
reader = New System.IO.StreamReader(responseStream)
theHtml = reader.ReadToEnd()
' Now create the mshtml object and get its title
Dim doc As IHTMLDocument2 = New HTMLDocument()
doc.write(theHtml)
Dim title As String = doc.title
Console.WriteLine(title)
Console.ReadLine()
End Sub
End Module