Public Class Form1
Dim wb As New WebBrowser With {.ScriptErrorsSuppressed = False}
Dim wc As New Net.WebClient()
Private url As String = "http://downloadinfo.html-5.me/Profile/"
Private htmlSource As String
Private cookie As String
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Button1.Enabled = False
wb.Navigate(url)
AddHandler wb.DocumentCompleted, AddressOf wb_DocumentCompleted
End Sub
Private Sub wb_DocumentCompleted(sender As System.Object, e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs)
cookie = sender.Document.Cookie
wc.Headers.Add(Net.HttpRequestHeader.Cookie, cookie)
htmlSource = wc.DownloadString(url)
Dim Matches As System.Text.RegularExpressions.MatchCollection = System.Text.RegularExpressions.Regex.Matches(htmlSource, "(?<=href="").+?(?="")")
If Not IO.Directory.Exists("Images") Then IO.Directory.CreateDirectory("Images")
For Each s As System.Text.RegularExpressions.Match In Matches
If s.Value.EndsWith(".png") Then
Dim filename As String = If(s.Value.StartsWith("http"), s.Value, url & s.Value)
'Me.ListBox1.Items.Add(filename)
Dim d() As Byte = wc.DownloadData(filename)
Image.FromStream(New IO.MemoryStream(TryCast(d, Array))).Save("Images\" & IO.Path.GetFileName(filename))
End If
Next
Button1.Enabled = True
MsgBox("تم حفظ الصور")
End Sub
'Private Sub ListBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
' Dim d() As Byte = wc.DownloadData(ListBox1.SelectedItem)
' PictureBox1.Image = Image.FromStream(New IO.MemoryStream(TryCast(d, Array)))
'End Sub
End Class