1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Visual Basic Coding Question

Discussion in 'Black Hat SEO Tools' started by phpfail, Jul 13, 2012.

  1. phpfail

    phpfail Regular Member

    Joined:
    Aug 21, 2011
    Messages:
    237
    Likes Received:
    104
    Occupation:
    Webmaster / Internet Marketer
    ** RESOLVED ** thanks for the help.

    Okay so I've been coding a bot and I've ran into a problem, it's the only thing holding back the completion of my bot. The bot is trying to click a button on a page, but theres more then one button and theres no unique identifier, so all the buttons are the same code, so the bot ends up clicking all the buttons on the page. The only unique identifier is the div id which surrounds each button.

    Example
    Code:
    <div id="93edufjai" name="whatever">
    some random code /text
    
    <button type="button">
    
    </div>
    
    So my question is this, how would I get the bot to click the button within the specified div with the correct ID, here is my code I'm using but it clicks all buttons not the button within the div.

    Code:
          For Each element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("div")
                If element.GetAttribute("id") = "93edufjai" Then
            For Each ele As HtmlElement In WebBrowser1.Document.GetElementsByTagName("button")
                If ele.GetAttribute("type") = "submit" Then
                    ele.InvokeMember("click")
                End If
            Next
    End If
    Next
    

    If anyone could help me I'd greatly appreciate it and maybe do something for you in return, I can code php and design very clean and professional websites. Or I can send you some money on paypal when I get paid next week. Thanks in advance for any help
     
    Last edited: Jul 13, 2012
  2. phpfail

    phpfail Regular Member

    Joined:
    Aug 21, 2011
    Messages:
    237
    Likes Received:
    104
    Occupation:
    Webmaster / Internet Marketer
    I was going to in a later version, just need to get it functioning first, i was going to ditch the web browser in a later version of the program, do you know how to fix my problem?
     
  3. Mission Ashwamedh

    Mission Ashwamedh Junior Member

    Joined:
    Jul 4, 2012
    Messages:
    187
    Likes Received:
    118
    Occupation:
    Software Development and Internet Marketing
    var butt = webBrowser1.Document.GetElementsByTagName("button").Cast<HtmlElement>().FirstOrDefault(bt => ((bt.Parent.TagName == "div") && (bt.Parent.Id == "93edufjai"))); if (butt != null) { butt.InvokeMember("click"); }
     
  4. Mission Ashwamedh

    Mission Ashwamedh Junior Member

    Joined:
    Jul 4, 2012
    Messages:
    187
    Likes Received:
    118
    Occupation:
    Software Development and Internet Marketing
    nothing wrong in using webbrowser ... those who don't know how to use it correctly complains..
     
  5. phpfail

    phpfail Regular Member

    Joined:
    Aug 21, 2011
    Messages:
    237
    Likes Received:
    104
    Occupation:
    Webmaster / Internet Marketer
    Is this for visual basic? I get a bunch of errors, I know its written in javascript, but I've never used visual basic in javascript, I'll do some googling and see if/how to use js in visual basic. Thank you so much tho!

    Also, the div id is not named just id,its data-id, so im unsure of how to change the parent.id to get the data-id
     
    Last edited: Jul 13, 2012
  6. Mission Ashwamedh

    Mission Ashwamedh Junior Member

    Joined:
    Jul 4, 2012
    Messages:
    187
    Likes Received:
    118
    Occupation:
    Software Development and Internet Marketing
    Dim butt = webBrowser1.Document.GetElementsByTagName("button").Cast(Of HtmlElement)().FirstOrDefault(Function(bt) ((bt.Parent.TagName = "div") AndAlso (bt.Parent.Id = "93edufjai")))If butt IsNot Nothing Then butt.InvokeMember("click")End If
     
  7. phpfail

    phpfail Regular Member

    Joined:
    Aug 21, 2011
    Messages:
    237
    Likes Received:
    104
    Occupation:
    Webmaster / Internet Marketer
    I'm getting a "expecting end of statement" error right at "If butt"
     
  8. phpfail

    phpfail Regular Member

    Joined:
    Aug 21, 2011
    Messages:
    237
    Likes Received:
    104
    Occupation:
    Webmaster / Internet Marketer
    sorry for all of the hassle, but I really appriciate it. Also the name of the div id is dat-id now just id, so i dont think parent id would work
     
  9. phpfail

    phpfail Regular Member

    Joined:
    Aug 21, 2011
    Messages:
    237
    Likes Received:
    104
    Occupation:
    Webmaster / Internet Marketer
    It is a comment upvoter but not for youtube, but I looked at youtube's coding and it is very similar, but instead of div youtube uses li