Results 1 to 3 of 3

Thread: Loop for a web bot

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2011
    Posts
    105

    Resolved Loop for a web bot

    well, i'm working in a bot for a web page, i know how to get the values of things that i want, but i have a problem.
    When i do that..
    Code:
                Dim allelements As HtmlElementCollection = WebBrowser1.Document.All
                For Each webpageelement As HtmlElement In allelements
                    If webpageelement.GetAttribute("className") = "mi_class_name_asd" Then
                        frmPreciosEncontrados.Label23.Text = webpageelement.InnerText
                    End If
                Next
    I get the first value of a list of values, all of them have the same classname( in the code ' mi_class_name_asd', for using it in a string in other form.
    What i want is to get ten values with the same classname and put it in different strings.

    Idk how to do it..

    Sorry if bad english, im spanish and my level of english is....
    Thanks for all and i wait for a reply.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    Re: Loop for a web bot

    Instead of setting the Text of the same Label each time, Add the values to a List(Of String). Once the loop is done you can then Join that list into one String or do whatever else is appropriate.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2011
    Posts
    105

    Re: Loop for a web bot

    EDIT: Loop is done perfectly. In the list appears all i need.
    Code I used:
    Code:
                Dim PageElement As HtmlElementCollection = WebBrowser1.Document.All
                For Each CurElement As HtmlElement In PageElement
                    If (CurElement.GetAttribute("className") = "mi class name") Then
                        Form1.ListBox1.Items.Add(CurElement.GetAttribute("innerText").ToString)
                    End If
                Next

    Im wanna make a switch with a string to set the other strings.
    Thanks for all.
    And plz dont close the post, i will tell if works or i need more help..
    Last edited by public; Sep 1st, 2013 at 08:03 PM.

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