منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
[سؤال] جلب روابط هذه الصفحة - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : قسم لغة الفيجوال بيسك VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=182)
+--- قسم : قسم اسئلة VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=183)
+--- الموضوع : [سؤال] جلب روابط هذه الصفحة (/showthread.php?tid=23665)



جلب روابط هذه الصفحة - ابو روضة - 04-02-18

السلام عليكم ورحمة الله وبركاته
كنت اريد جلب مواضيع هذا الموقع بالويب براوزر
http://articles.islamweb.net/media/index.php?page=maincategory&lang=A&vPart=49
داخل الليست بوكس وتكون بالاسماء
وجربت هذا الكود ولم يفلح للأسف

كود :
Public Class Form1
   Dim aaa As New List(Of String)
   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       Dim aa As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("div")
       For Each s As HtmlElement In aa
           If s.GetAttribute("className").Contains("ItemTitle") Then
               aaa.Add(s.GetAttribute("href"))
               ListBox1.Items.Add(s.InnerText)

           End If
       Next
   End Sub

   Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
       Process.Start(aaa(sender.selectedindex))
   End Sub
End Class



RE: جلب روابط هذه الصفحة - طالب برمجة - 04-02-18

وجدت لك هذه الطريقة بدون ويب براوزر
PHP كود :
Imports System.Text.RegularExpressions

Public Class Form1

    Dim dt 
As New DataTable

    Private Sub Form1_Load
(ByVal sender As ObjectByVal e As EventArgsHandles MyBase.Load
        dt
.Columns.Add("Title")
 
       dt.Columns.Add("URL")
 
   End Sub

    Private Sub Button1_Click
(ByVal sender As ObjectByVal e As EventArgsHandles Button1.Click
        Dim wc 
As New Net.WebClient
        Dim a 
As String wc.DownloadString("http://articles.islamweb.net/media/index.php?page=maincategory&lang=A&vPart=49")
 
       Dim b As MatchCollection Regex.Matches(a"(<div class=""ItemTitle"">).+?(</div>)"RegexOptions.Singleline)

 
       ListBox1.Items.Clear()
 
       For Each c As Match In b
            Dim d 
As String Regex.Match(c.Value"(?<=<font.+>).+?(?=</font>)").Value
            Dim u 
As String "http://articles.islamweb.net/media/" Regex.Match(c.Value"(?<=href="").+?(?="")").Value
            dt
.Rows.Add(du)
 
       Next
        ListBox1
.DataSource dt
        ListBox1
.DisplayMember "Title"
 
       ListBox1.ValueMember "URL"
 
   End Sub

    Private Sub ListBox1_SelectedIndexChanged
(ByVal sender As ObjectByVal e As EventArgsHandles ListBox1.SelectedIndexChanged
        If ListBox1
.SelectedValue.GetType IsNot GetType(DataRowViewThen
            Process
.Start(sender.SelectedValue)
 
       End If
 
   End Sub

End 
Class 



RE: جلب روابط هذه الصفحة - ابو روضة - 04-02-18

(04-02-18, 04:58 AM)طالب برمجة كتب : وجدت لك هذه الطريقة بدون ويب براوزر
PHP كود :
Imports System.Text.RegularExpressions

Public Class Form1

    Dim dt 
As New DataTable

    Private Sub Form1_Load
(ByVal sender As ObjectByVal e As EventArgsHandles MyBase.Load
        dt
.Columns.Add("Title")
 
       dt.Columns.Add("URL")
 
   End Sub

    Private Sub Button1_Click
(ByVal sender As ObjectByVal e As EventArgsHandles Button1.Click
        Dim wc 
As New Net.WebClient
        Dim a 
As String wc.DownloadString("http://articles.islamweb.net/media/index.php?page=maincategory&lang=A&vPart=49")
 
       Dim b As MatchCollection Regex.Matches(a"(<div class=""ItemTitle"">).+?(</div>)"RegexOptions.Singleline)

 
       ListBox1.Items.Clear()
 
       For Each c As Match In b
            Dim d 
As String Regex.Match(c.Value"(?<=<font.+>).+?(?=</font>)").Value
            Dim u 
As String "http://articles.islamweb.net/media/" Regex.Match(c.Value"(?<=href="").+?(?="")").Value
            dt
.Rows.Add(du)
 
       Next
        ListBox1
.DataSource dt
        ListBox1
.DisplayMember "Title"
 
       ListBox1.ValueMember "URL"
 
   End Sub

    Private Sub ListBox1_SelectedIndexChanged
(ByVal sender As ObjectByVal e As EventArgsHandles ListBox1.SelectedIndexChanged
        If ListBox1
.SelectedValue.GetType IsNot GetType(DataRowViewThen
            Process
.Start(sender.SelectedValue)
 
       End If
 
   End Sub

End 
Class 

برغم انى كنت محتاج وبشدة ان اجلبها بالويب براوزر لانى لا افهم Regex
لكن كتر الف خيرك والله فدائما تمّد لى يدى المساعدة فى ألوقت المناسب ولم تبخل
فجزاك الله كل خير استاذى