Results 1 to 11 of 11
  1. #1
    alvaritos's Avatar
    Join Date
    May 2008
    Gender
    male
    Posts
    234
    Reputation
    9
    Thanks
    73
    My Mood
    Amazed

    Webrowser get links [solved]

    Code:
     Dim htmlDocument As HtmlDocument = Me.WebBrowser1.Document
            Dim htmlElementCollection As HtmlElementCollection = htmlDocument.Links
            Dim link2 As HtmlElementCollection
            link2 = WebBrowser1.Document.GetElementsByTagName("href")
            For Each img As HtmlElement In link2
                ListBox1.Items.Add(img.GetAttribute("href"))
            Next
    The code dont work . . .
    I want the code Gets all the Links of the Webpage and add to listbox

    thanks

  2. #2
    SubCub's Avatar
    Join Date
    Feb 2011
    Gender
    male
    Location
    Clarion, Pa
    Posts
    695
    Reputation
    -32
    Thanks
    120
    My Mood
    Cheerful
    Explain more please.

  3. #3
    alvaritos's Avatar
    Join Date
    May 2008
    Gender
    male
    Posts
    234
    Reputation
    9
    Thanks
    73
    My Mood
    Amazed
    I want the code gets all the links in the Web and add to listbox..

  4. #4
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Quote Originally Posted by alvaritos View Post
    I want the code gets all the links in the Web and add to listbox..
    Again, use my toolkit. ParseAllLinks speaks for itself.

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)

  5. #5
    Lyoto Machida's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    Far away with girls
    Posts
    3,734
    Reputation
    133
    Thanks
    1,621
    My Mood
    Aggressive
    Code:
    Dim Links As HtmlElementCollection = WebBrowser1.Document.GetElementByTagName("a")
    
    For Each Link As HtmlElement in Links
    Listbox1.Items.Add(Link.GetAttribute("href").ToString)
    Next
    But this will get the links only of the tag "a" ..

    You cant just edit it to get the links of everytags, there are alots of ways..

    Sorry my english.
    Last edited by Lyoto Machida; 06-10-2011 at 11:00 AM.

  6. #6
    alvaritos's Avatar
    Join Date
    May 2008
    Gender
    male
    Posts
    234
    Reputation
    9
    Thanks
    73
    My Mood
    Amazed
    Well Jason Im at My father PC, I cant download it now . . . And im borring so im making a new tool :S

    Also thanks Lyoto

  7. #7
    Lyoto Machida's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    Far away with girls
    Posts
    3,734
    Reputation
    133
    Thanks
    1,621
    My Mood
    Aggressive
    Quote Originally Posted by alvaritos View Post
    Well Jason Im at My father PC, I cant download it now . . . And im borring so im making a new tool :S

    Also thanks Lyoto
    No problem, Anytime

  8. #8
    alvaritos's Avatar
    Join Date
    May 2008
    Gender
    male
    Posts
    234
    Reputation
    9
    Thanks
    73
    My Mood
    Amazed
    But. . . You said just get elements of "a" I change It to "www" no?

    Code:
    Dim htmlElementCollection As HtmlElementCollection = htmlDocument.All
    Dim link2 As HtmlElementCollection
    link2 = WebBrowser1.Document.Links
    For Each img As HtmlElement In link2
                varto = ListBox1.Items.Count
                ListBox1.Items.Add(img.GetAttribute("href"))
                Label2.Text = varto & " " & "Links"
                Label2.ForeColor = Color.Green
    Last edited by alvaritos; 06-10-2011 at 11:11 AM.

  9. #9
    Lyoto Machida's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Location
    Far away with girls
    Posts
    3,734
    Reputation
    133
    Thanks
    1,621
    My Mood
    Aggressive
    Just make a loop trough all elements of the page, And make like a check, If the attribute "href" is not null , then add it to the listbox..

  10. #10
    alvaritos's Avatar
    Join Date
    May 2008
    Gender
    male
    Posts
    234
    Reputation
    9
    Thanks
    73
    My Mood
    Amazed
    Well solved but anyway thanks!

  11. #11
    Jason's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    /dev/null
    Posts
    5,704
    Reputation
    918
    Thanks
    7,676
    My Mood
    Mellow
    Okay marked solved.

    [highlight=vb.net]
    ListBox1.Items.AddRange(WebBrowser1.Document.GetEl ementsByTagName("a").Cast(Of HtmlElement)().Select(Function(h As HtmlElement) h.GetAttribute("href").ToString()).ToArray())
    [/highlight]

    Quote Originally Posted by Jeremy S. Anderson
    There are only two things to come out of Berkley, Unix and LSD,
    and I don’t think this is a coincidence
    You can win the rat race,
    But you're still nothing but a fucking RAT.


    ++Latest Projects++
    [Open Source] Injection Library
    Simple PE Cipher
    FilthyHooker - Simple Hooking Class
    CLR Injector - Inject .NET dlls with ease
    Simple Injection - An in-depth look
    MPGH's .NET SDK
    eJect - Simple Injector
    Basic PE Explorer (BETA)