(24-03-21, 01:19 AM)معاند الحظ كتب : أنت على العين وعلى الراس اخوي ابو روضه وما يحتاج تعتذر
واللي سويته أنا شيئ بسيط وسهل .
طريقة استخراج الرابط الاول هى انك تخرج من الحلقه For Each link As HtmlElementباستخدام Exit For داخل الجملة الشرطية كالتاليكود :
For Each link As HtmlElement In wb.Document.Links
If link.GetAttribute("href").Contains("googlevideo.com") Then
rtxt.AppendText(link.GetAttribute("href") & vbNewLine)
Exit For
End If
Next
تسلملى عيونك أخى العزيز ربنا يكرمك ويبارك بعمرك...
تم الحل الحمدلله بفضل الله ثم خبرتك..
(24-03-21, 01:25 AM)أبو عبدالله الحلواني كتب :إقتباس :كيف استخرج أول رابط فقط من الروابط التى تم استخراجها ؟
استخدم متغير من نوع تكست مثل هذا التعديل لتجلب به أول قيمة فقط من الروابط
PHP كود :
Imports HtmlAgilityPack
Imports System.Text
Imports System.Net
Public Class Form
Dim WithEvents wb As New WebBrowser
Dim n as integer = 0
Dim FirstLink as string
Private Sub Form_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
wb.ScriptErrorsSuppressed = True
Button1.PerformClick()
End Sub
Private Sub Button1_Click_1(sender As System.Object, e As System.EventArgs) Handles Button1.Click
wb.Navigate(New Uri(TextBox1.Text))
End Sub
Private Sub wb_DocumentCompleted(sender As Object, e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles wb.DocumentCompleted
If wb.Document IsNot Nothing Then
For Each link As HtmlElement In wb.Document.Links
n+=1
If link.GetAttribute("href").Contains("googlevideo.com") Then
rtxt.AppendText(link.GetAttribute("href") & vbNewLine)
If n=1 then
FirstLink = link.GetAttribute("href")
End if
End If
Next
End If
End Sub
End Class
ربنا يكرمك ويبارك بعمرك أخى الغالى...

