منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : جلب الروابط داخل النصوص بالريجيكس
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
السلام عليكم اخوتى
كيف اجلب الروابط داخل الاسماء من خلال الريجيكس
فانا اجلب الاسماء فقط هكذا على سبيل المثال

كود :
Dim web As New WebClient()
       web.Encoding = Encoding.Default
       Dim result As String = web.DownloadString("https://www.gametop.com/category/windows-7-games.html")
       Dim a12 As MatchCollection = Regex.Matches(result, "<h3 class=""title"">(.+?)<\/h3>", RegexOptions.IgnoreCase)
       For i = 0 To a12.Count - 1
           ListBox1.Items.Add(a12(i).Groups(1).Value)
       Next

فكيف أدمج الرابط داخل الاسم كما نفعل بالويب براوزر والHtmlAgilityPack  فهذا الكود مثلا يجلب الرابط
داخل الاسم

كود :
For Each n As HtmlAgilityPack.HtmlNode In doc.DocumentNode.SelectNodes("//tr/td/font/a")
           ListBox1.Items.Add(n.InnerText)
           lst.Add("http://saaid.net/tarbiah/" & n.Attributes("href").Value)
           Me.Text = ListBox1.Items.Count
       Next

ولكنى لم أتطرق لها فى الريجيكس الى االان أو لم افهمها
فلو سمحتم ممكن طريقة مبسطة افهم بها
عمال احاول وحاولت بهذا الكود وبتجبلى الخانات فاضية مع ان فعلا عدد المواضيع 50

كود :
 Dim url As String = "https://www.gametop.com/category/windows-7-games.html"
       Dim wc As New WebClient
       wc.Encoding = Encoding.Default
       Dim html As String = wc.DownloadString(url)
       Dim r = Regex.Matches(html, "<div class=""card"">", RegexOptions.IgnoreCase)
       For Each t As Match In r
           ListBox1.Items.Add(Regex.Match(t.Value, "<h3 class=""title"">(.+?)<\/h3>").Groups(1).Value)
           lst.Add(Regex.Match(t.Value, "<a href=""(.+?)").Groups(1).Value)
       Next

وعليكم السلام اخي 

اتفضل هذا الكود ان كنت تريد جلب هاذي الروابط

كود :
Dim web As New WebClient()
       web.Encoding = Encoding.Default
       Dim result As String = web.DownloadString("https://www.gametop.com/category/windows-7-games.html")
       Dim matchs As MatchCollection = Regex.Matches(result, "<a href='(.*)' onclick=""ga", RegexOptions.Compiled + RegexOptions.Multiline)
       Dim match As Match
       For Each match In matchs
           ListBox2.Items.Add(match.Groups.Item(1).ToString)
       Next
وان كنت تريد الحصول على روابط اخرى قم بتحديد السطر داخل السورس الصفحة وضع قوسين وبنص القوسين .* وهية تحديد الكلمات  المختلفة 
(30-11-18, 02:52 PM)XBOOBX كتب : [ -> ]
وعليكم السلام اخي 

اتفضل هذا الكود ان كنت تريد جلب هاذي الروابط

كود :
Dim web As New WebClient()
       web.Encoding = Encoding.Default
       Dim result As String = web.DownloadString("https://www.gametop.com/category/windows-7-games.html")
       Dim matchs As MatchCollection = Regex.Matches(result, "<a href='(.*)' onclick=""ga", RegexOptions.Compiled + RegexOptions.Multiline)
       Dim match As Match
       For Each match In matchs
           ListBox2.Items.Add(match.Groups.Item(1).ToString)
       Next
وان كنت تريد الحصول على روابط اخرى قم بتحديد السطر داخل السورس الصفحة وضع قوسين وبنص القوسين .* وهية تحديد الكلمات  المختلفة 
جزاك الله كل خير اخى لكنها بتجلب الروابط فقط
وانا اريد الرابط مدموج داخل الاسم بحيث يظهر فى الليست بوكس الاسم وحين
الضغط عليه ينتقل الى الرابط....
هو اخ فاضل هنا الله يكرمه حلها اصلا لكن كل شخص وله طريقة فيمكن طريقتك تفيد ايضا