03-05-14, 01:20 AM
-
تم تعديل المثال السابق وذلك باستخدام If HtmlNode.Attributes("...") IsNot Nothing وهي الطريقة الصحيحة في مثل هذه الحالة....تم استخدام Distinct لحذف المكرر.....
تم تعديل المثال السابق وذلك باستخدام If HtmlNode.Attributes("...") IsNot Nothing وهي الطريقة الصحيحة في مثل هذه الحالة....تم استخدام Distinct لحذف المكرر.....
كود :
Dim htmldoc As HtmlDocument = New HtmlDocument()
htmldoc.Load("abc.html")
Dim hrefs, classs As New List(Of String)
For Each link As HtmlNode In htmldoc.DocumentNode.SelectNodes("//a")
If link.Attributes("href") IsNot Nothing Then hrefs.Add(link.Attributes("href").Value)
If link.Attributes("class") IsNot Nothing Then classs.Add(link.Attributes("class").Value)
Next
MsgBox("hrefs:" & vbNewLine & Join(hrefs.Distinct.ToArray, vbNewLine))
MsgBox("classes:" & vbNewLine & Join(classs.Distinct.ToArray, vbNewLine))


