Results 1 to 7 of 7

Thread: [RESOLVED] Using Webbrowser control with Text Document

Threaded View

  1. #1

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,826

    Resolved [RESOLVED] Using Webbrowser control with Text Document

    I'm trying to pull specific information from a website using the webbrowser control. Using something like this:
    vb.net Code:
    1. If chkSears.Checked And chk46V5100.Checked = True Then
    2.             WebBrowser1.Navigate("http://www.sears.com/shc/s/p_10153_12605_05772639000P?vName=Computers+%26+Electronics&cName=Televisions&sName=Flat+Panel")
    3.             While Not WebBrowser1.ReadyState = WebBrowserReadyState.Complete
    4.                 Application.DoEvents()
    5.             End While
    6.             If WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
    7.                 For Each DivTag As HtmlElement In WebBrowser1.Document.GetElementsByTagName("span")
    8.                     Dim s = DivTag.GetAttribute("className")
    9.                     If s IsNot Nothing AndAlso s = "pricing" Then
    10.                         TextBox1.Text = (DivTag.OuterText)
    11.                     End If
    12.                 Next
    13.             End If
    14.         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:
    1. If chkSears.Checked And chk32S5100.Checked = True Then
    2.             Dim wc As New System.Net.WebClient()
    3.             wc.DownloadFile("http://www.sears.com/shc/s/p_10153_12605_05772639000P?vName=Computers+%26+Electronics&cName=Televisions&sName=Flat+Panel", "C:\file.txt")
    4.             WebBrowser1.Navigate("C:\file.txt")
    5.             For Each DivTag As HtmlElement In WebBrowser1.Document.GetElementsByTagName("span")
    6.                 Dim s = DivTag.GetAttribute("className")
    7.                 If s IsNot Nothing AndAlso s = "pricing" Then
    8.                     txt32S5100sears.Text = (DivTag.OuterText)
    9.                 End If
    10.             Next
    11.         End If

    That's the code I'm trying to use.

    If anyone has any suggestions or another method, I would appreciate it.

    Thanks
    Last edited by weirddemon; May 24th, 2009 at 01:42 PM.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width