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

VB.NET 08 How do i click on this? <li><a href="register.php" rel="nofollow">Register<

Discussion in 'Visual Basic 6' started by simpleonlinetest, Feb 5, 2011.

  1. simpleonlinetest

    simpleonlinetest Regular Member

    Joined:
    Feb 18, 2010
    Messages:
    208
    Likes Received:
    25
    <li><a href="register.php" rel="nofollow">Register</a></li>



    Driving me nuts..I'm trying to create forum type software but I can't seem to figure out how to programmically click on this link

    Any ideas? Tried by id and by tag but there isn't one for this...what is the work around for this?

    Thanks
     
  2. blakamia

    blakamia Junior Member

    Joined:
    Jan 25, 2010
    Messages:
    162
    Likes Received:
    348
    Are you using the Webbrowser control?
     
  3. homenet

    homenet Power Member

    Joined:
    Jan 5, 2009
    Messages:
    790
    Likes Received:
    338
    Location:
    Dimension X
    If your using the web browser control then:

    webbrowser1.navigate("http://www.vb.net/register.php")
     
  4. captchaman

    captchaman Junior Member

    Joined:
    Sep 16, 2010
    Messages:
    190
    Likes Received:
    842
    Occupation:
    Software Programmer
    Location:
    USA
    I believe this will work...

    Code:
    If InStr("<li><a href="register.php" rel="nofollow">Register</a></li>", "href=http:") Then
    ' Go to everything that was parsed
    Else
    GetBetween("<li><a href="register.php" rel="nofollow">Register</a></li>", "href="", "")
    'Navigate to currentURL & "\" & whatever you just parsed.
    End if
    GetBetween function:
    Code:
        Public Function GetBetween(ByRef strSource As String, ByRef strStart As String, ByRef strEnd As String, Optional ByRef startPos As Integer = 0) As String
            Dim iPos As Integer, iEnd As Integer, lenStart As Integer = strStart.Length
            Dim strResult As String
    
            strResult = String.Empty
            iPos = strSource.IndexOf(strStart, startPos)
            iEnd = strSource.IndexOf(strEnd, iPos + lenStart)
            If iPos <> -1 AndAlso iEnd <> -1 Then
                strResult = strSource.Substring(iPos + lenStart, iEnd - (iPos + lenStart))
            End If
            Return strResult
        End Function
     
  5. pyronaut

    pyronaut Supreme Member

    Joined:
    Dec 9, 2008
    Messages:
    1,229
    Likes Received:
    1,425
    Depending on what controls you are using (Are you doing it via webrequests or via Browser). You should be able to get the collection/array of links. From there you can test them for anchor text and/or the link to find it.
     
  6. KirtiD

    KirtiD Newbie

    Joined:
    Jun 13, 2013
    Messages:
    49
    Likes Received:
    15
    Location:
    Beed
    here is easy way
    Dim dom = doc.GetElementsByTagName("a")
    For Each temp As HtmlElement In dom
    If temp.GetAttribute("href").Contains("register") Then
    Dim navUrl As String = temp.GetAttribute("href")
    temp.InvokeMember("click")