I'm trying to pull specific information from a website using the webbrowser control. Using something like this:vb.net Code:
If chkSears.Checked And chk46V5100.Checked = True Then WebBrowser1.Navigate("http://www.sears.com/shc/s/p_10153_12605_05772639000P?vName=Computers+%26+Electronics&cName=Televisions&sName=Flat+Panel") While Not WebBrowser1.ReadyState = WebBrowserReadyState.Complete Application.DoEvents() End While If WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then For Each DivTag As HtmlElement In WebBrowser1.Document.GetElementsByTagName("span") Dim s = DivTag.GetAttribute("className") If s IsNot Nothing AndAlso s = "pricing" Then TextBox1.Text = (DivTag.OuterText) End If Next End If End If
When doing a search (ctrl+f) through the HTML, I only find one span tag that has its class name as pricing. But, when I run the code, I get a completely different price. I think the problem is that the page might be linked to another or something along those lines.
So, I decided to try a different approach. I wanted to download the HTML into a text file and use the same approach. It loads the information into the webbrowser control, which is good. But it doens't pull the info like it does on a website.
vb.net Code:
If chkSears.Checked And chk32S5100.Checked = True Then Dim wc As New System.Net.WebClient() wc.DownloadFile("http://www.sears.com/shc/s/p_10153_12605_05772639000P?vName=Computers+%26+Electronics&cName=Televisions&sName=Flat+Panel", "C:\file.txt") WebBrowser1.Navigate("C:\file.txt") For Each DivTag As HtmlElement In WebBrowser1.Document.GetElementsByTagName("span") Dim s = DivTag.GetAttribute("className") If s IsNot Nothing AndAlso s = "pricing" Then txt32S5100sears.Text = (DivTag.OuterText) End If Next End If
That's the code I'm trying to use.
If anyone has any suggestions or another method, I would appreciate it.
Thanks




Reply With Quote