Results 1 to 6 of 6

Thread: Go Fetch!

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2000
    Location
    I'm right here!
    Posts
    849
    I need to do a procedure that will go in to a web site,
    get his source, add every link to a ListView and will
    be able to show the link in a WebBrowser Control.
    Dekel C.

  2. #2
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    hmm

    use the inet control
    t

  3. #3
    Guest
    To read a webpage from the Webbrowser Control:

    Code:
    Text1.Text = Webbrowser1.Document.documentElement.innerHTML
    To add to a listview:

    Code:
    ListView1.ListItems.Add , , "Item"
    To extract links from a string:

    Code:
    'ExtractLinks str As String, baseurl As String
    'Str is the String To extract links from, base url is the url to use as the base url If no <base href=...> tag is found.
    '
    To display your links:
    Make 2 list boxes, list1 and list2
    In a button put:
    
    Private Sub Command1_Click()
    For x=1 To ubound(LinkBuffer)
    
    
        doevents
            list1.additem linkbuffer(x).TAG
            list2.additem linkbuffer(x).URL
        Next x
    End Sub
    '
    Public Type Link
        URL As String
        Tag As String
        End Type
        Global LinkBuffer() As Link
    
    
    Public Sub ExtractLinks(str As String, baseurl As String)
        Erase LinkBuffer()
        ReDim LinkBuffer(0)
        thea = InStr(1, LCase(str), "<a ")
        bizace = InStr(1, LCase(str), "<base ") + 6
    
    
        If bizace <> 0 Then
            endofbase = InStr(bizace, str, ">") + 1
            If endofbase = 0 Then Goto nobase
            thebasetag = Mid(str, bizace, endofbase - bizace)
            basehrefloc = InStr(1, LCase(thebasetag), "href=")
            If basehrefloc = 0 Then Goto nobase
            basehrefend = InStr(href, thewholelink, " ")
            If basehrefend = 0 Then basehrefend = InStr(basehrefloc, thebasetag, ">")
            If basehrefend = 0 Then Goto nobase
            baseurl = Mid(thebasetag, basehrefloc + 5, basehrefend - basehrefloc)
            If Right$(baseurl, 1) = ">" Then baseurl = Mid(baseurl, 1, Len(baseurl) - 1)
            If Left$(baseurl, 1) = """" Then baseurl = Mid(baseurl, 2)
            If Right$(baseurl, 1) = """" Then baseurl = Mid(baseurl, 1, Len(baseurl) - 1)
        End If
        nobase:
    
    
        Do While thea <> 0
            endoflink = InStr(thea, LCase(str), "</a>") + 3
            If endoflink = 0 Then Goto Invalid
            thewholelink = Mid(str, thea, endoflink)
            endofh = InStr(1, thewholelink, ">")
            firsthalf = Mid(thewholelink, 1, endofh)
            
            
            href = InStr(1, firsthalf, "href=") + 5
            If href = 0 Then Goto Invalid
            endofurl = InStr(href, firsthalf, " ")
            If endofurl = 0 Then endofurl = InStr(href, firsthalf, ">")
            If endofurl = 0 Then Goto nobase
            theurl = Mid(firsthalf, href, endofurl - href)
            tagend = InStr(1, LCase(thewholelink), "</a>") - 1
            thetag = Mid(thewholelink, Len(firsthalf) + 1, tagend - Len(firsthalf))
            If Left$(theurl, 1) = """" Then theurl = Mid(theurl, 2)
            If Right$(theurl, 1) = """" Then theurl = Mid(theurl, 1, Len(theurl) - 1)
    
    
            If Mid(theurl, 4, 3) <> "://" Then
                If Left$(theurl, 1) <> "/" Then theurl = "/" & theurl
                If Right$(baseurl, 1) = "/" Then baseurl = Left$(baseurl, Len(baseurl) - 1)
                theurl = baseurl & theurl
            End If
            ReDim Preserve LinkBuffer(UBound(LinkBuffer) + 1)
            LinkBuffer(UBound(LinkBuffer)).Owner = CurrentURL
            LinkBuffer(UBound(LinkBuffer)).Tag = thetag
            Invalid:
    
    
            DoEvents
                If endoflink = 0 Then endoflink = thea + 1
                thea = InStr(endoflink, LCase(str), "<a ")
            Loop
        End Sub

  4. #4
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    hmm

    Matthew,
    r u bill's big brother by any chance?

  5. #5
    Guest

    Exclamation *TOP SECRET*

    Why do you ask?

  6. #6
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    Wink top investigator...

    hmm

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