Results 1 to 2 of 2

Thread: Getting Links From WebPage

  1. #1
    Addicted Member
    Join Date
    Nov 11
    Location
    Ohio
    Posts
    172

    Getting Links From WebPage

    Hey everyone I am a little lost on this. How would I get links from a webpage and save them to a txt file? I have a button that navigates to my webpage which is button1 and then I have a listbox that I would like to list the links in. All of the links are href but I would only like to get the links that contain vk. Any help would be great.

  2. #2
    PowerPoster kevininstructor's Avatar
    Join Date
    Jun 08
    Location
    Oregon
    Posts
    5,067

    Re: Getting Links From WebPage

    The following is easy to follow

    Code:
    Private Sub Form1_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
        WebBrowser1.Url = New Uri("http://www.jimjacobe.com/LinksMain.html")
        While WebBrowser1.ReadyState <> WebBrowserReadyState.Complete
            Application.DoEvents()
        End While
    End Sub
    Code to get links, place say in a button click event
    Code:
    Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("a")
    For Each curElement As HtmlElement In theElementCollection
        Dim hRef As String = curElement.GetAttribute("href").ToString
        Console.WriteLine("{0} - {1}", hRef, curElement.InnerText)
    Next
    Results
    Code:
    http://www.jimjacobe.com/index.html - Main page Return to Jim's main page
    http://www.jimjacobe.com/ClassDescriptions.html - Classes This page describes current classes offered by Jim
    http://www.jimjacobe.com/Calendar/CurrentMonth.html - Classes dates Class dates
    http://www.jimjacobe.com/Directions.html - Directions This page has Directions to classroom
    http://www.jimjacobe.com/Bulletins.html - Bulletins View Bulletins and special alerts
    http://www.jimjacobe.com/Books_1.html - Books View books available for sale in the class room
    http://www.jimjacobe.com/LinksMain.html# - Class photos Here you will find some pictures for some of Jim's classes
    http://www.arpc.info/ - Albany Rifle and Pistol Club
    http://nelsonleather.com/ - A. E. Nelson Leather Company
    http://www.bigboyguntoys.com/ - Big Boy Gun Toys
    http://www.tedblockerholsters.com/ - Ted Blocker
    http://www.corneredcat.com/ - Corner Cat
    http://www.crimsontrace.com/ - Crimson Trace
    http://dillonprecision.com/default.cfm? - Dillon Precision
    http://www.firearmsacademy.com/ - Firearms Academy of Seattle
    http://www.first-light-usa.com/ - First-Light
    http://home.comcast.net/~kevininstructor/ - Kevin Gallagher
    http://www.killology.com/ - Killology
    http://www.kramerleather.com/ - Kramer Leather
    http://www.ayoob.com/ - Lethal Force Institute
    http://www.lhggunsmithing.com/ - LHG
    http://www.littlebeargunshop.com/ - Little Bear Gun Shop
    http://www.handgunlaw.us/ - Handgun laws
    http://debbevonblumenstein.net/legal_home.htm - hotpotato press
    http://www.maghinayinvestigations.com/ - Jennifer Maghinay, PI
    http://www.ossa.org/ - Oregon State Shooting Association
    http://www.zielkelaw.com/ - The Zielke Law Firm
    mailto:gallaghe@teleport.com - Kevin S. Gallagher
    http://www.jimjacobe.com/index.html - Home
    http://www.ayoob.com/ - Lethal Force Institute
    http://www.firearmsacademy.com/ - Firearms Academy of Seattle
    http://www.handgunlaw.us/ - www.handgunlaw.us
    mailto:jimjacobe@comcast.net - email

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •