<html>
 
<td id="item_menu" class="line" valign="top" width="100%">
		<a class="nopd" target="mainly"  href="http://myfruits/aboutfruits.html">About fruits</a>
</td>				 
<td class="line" id="item_menu" valign="top" width="100%">	
<b>Common Fruits</b>				
<div class="tree tree-top" style="-moz-user-select: none;"><div class=" tree-item tree-lines-t" style="-moz-user-select: none;"><table class="tree-table" style="-moz-user-select: none;" cellpadding="0" cellspacing="0"><tbody style="-moz-user-select: none;"><tr style="-moz-user-select: none;"><td class="tgb icon customIcon" style="-moz-user-select: none;"></td><td class="label" style="-moz-user-select: none;"><a href="http://myfruits/apple.html" target="cmain" title="CONTENT: TOC">Apple</a></td></tr></tbody></table></div>
<div class="tree tree-top" style="-moz-user-select: none;"><div class=" tree-item tree-lines-t" style="-moz-user-select: none;"><table class="tree-table" style="-moz-user-select: none;" cellpadding="0" cellspacing="0"><tbody style="-moz-user-select: none;"><tr style="-moz-user-select: none;"><td class="tgb icon customIcon" style="-moz-user-select: none;"></td><td class="label" style="-moz-user-select: none;"><a href="http://myfruits/orange.html" target="cmain" title="CONTENT: TOC">Orange</a></td></tr></tbody></table></div>
			
</td>
		
</html>

I was able to grab all the links in that html code But i want to grab all the links that is under

<td class="line" id="item_menu" valign="top" width="100%">	
<b>Common Fruits</b>

I was wondering how do I can grab the the links under the "Common fruits"
how to get grab http://myfruits/orange.html and a http://myfruits/apple.html in that table

Recommended Answers

What do you mean by "grabbing"?

Btw, you should consider formatting and indenting your code for easier comprehension.

Jump to Post

All 2 Replies

What do you mean by "grabbing"?

Btw, you should consider formatting and indenting your code for easier comprehension.

See if this helps.

Public Class Form1
    Private myFile As String = "C:\test.html" '// File for testing.

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Show()
        '// send file lines as a Array.
        getLinks(IO.File.ReadAllLines(myFile))
    End Sub

    Private Sub getLinks(ByVal htmlContentLines() As String)
        Dim iStartIndex, iEndIndex As Integer '// used to locate content to extract.
        For Each htmlLine As String In htmlContentLines '// loop thru all lines.
            If htmlLine.Contains("<div class=""tree tree-top""") Then '// locate lines that contain your links.
                iStartIndex = htmlLine.IndexOf("http://") '// get start location of link.
                iEndIndex = htmlLine.IndexOf("""", iStartIndex) '// get end location of link.
                MsgBox(htmlLine.Substring(iStartIndex, iEndIndex - iStartIndex)) '// extract link.
            End If
        Next
    End Sub
End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.