Results 1 to 6 of 6

Thread: [RESOLVED] Web Scrapping (getting output from the web)

Hybrid View

  1. #1

    Thread Starter
    Hyperactive Member JXDOS's Avatar
    Join Date
    Aug 2006
    Location
    Mars...
    Posts
    423

    Resolved [RESOLVED] Web Scrapping (getting output from the web)

    Hi,
    I am trying to extract some data from the webpage's element. Since it is based on the input I type in, the length of the output is different for every different input.

    The format of the data I am trying to extract is always as follows:

    <div id="result"><div style="padding:0.6em;">Vast</div></div>

    I want what ever word/phrase of any length that is between "0.6em;">" and "</div>"

    earlier methods I've used for inputs was WebBrowser1.Document.GetElementById("Text").SetAttribute("value", TextBox1.Text)

    I was wondering if there is something as simple for extracting the output.

    Thanks in advance
    Last edited by JXDOS; Feb 7th, 2011 at 07:30 AM.
    If my post has been helpful, please rate it!

  2. #2
    Fanatic Member
    Join Date
    Aug 2010
    Posts
    624

    Re: Web Scrapping (getting output from the web)

    You can try:

    vb Code:
    1. Dim elem As HtmlElement = WebBrowser1.Document.GetElementByID("result")
    2. Dim innerString As String = elem.InnerText
    3. MsgBox(innerString)
    If I helped you out, please take the time to rate me

  3. #3

    Thread Starter
    Hyperactive Member JXDOS's Avatar
    Join Date
    Aug 2006
    Location
    Mars...
    Posts
    423

    Re: Web Scrapping (getting output from the web)

    Actually, thanks so much. I just realised it was because the webpage didn't finish loading.
    Last edited by JXDOS; Feb 7th, 2011 at 05:59 AM.
    If my post has been helpful, please rate it!

  4. #4

    Thread Starter
    Hyperactive Member JXDOS's Avatar
    Join Date
    Aug 2006
    Location
    Mars...
    Posts
    423

    Re: Web Scrapping (getting output from the web)

    What if there isn't an Id? Like in the example below:

    Code:
    <div  class="dct-em"> 
    <span class="dct-tt">A rope with its ends fastened at different points to a spar or other object in order to provide a purchase</span> 
    </div> 
    </li> 
    <li class="dct-em"
                   > 
    <div  class="dct-em"> 
    <span class="dct-tt">A team of people or animals, in particular</span> 
    </div> 
    </li> 
    <li class="dct-em"
                   > 
    <div  class="dct-em"> 
    <span class="dct-tt">A matched pair of horses, mules, or oxen</span> 
    </div>
    I just want to extract the 3 chunks of text.
    If my post has been helpful, please rate it!

  5. #5
    Fanatic Member
    Join Date
    Aug 2010
    Posts
    624

    Re: Web Scrapping (getting output from the web)

    Try something like this:

    vb.net Code:
    1. Dim InnerStringEnum As IEnumerable(Of String) = From h As HtmlElement In WebBrowser1.Document.GetElements.GetElementsByTagName("span") _
    2. Where h.GetAttribute("className").Equals("dct-tt") _
    3. Select h.InnerText
    4.  
    5. For each s As String in InnerStringEnum
    6.     MsgBox(s)
    7. Next
    If I helped you out, please take the time to rate me

  6. #6

    Thread Starter
    Hyperactive Member JXDOS's Avatar
    Join Date
    Aug 2006
    Location
    Mars...
    Posts
    423

    Re: Web Scrapping (getting output from the web)

    Thanks again, your solutions work great!
    If my post has been helpful, please rate it!

Tags for this Thread

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