⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmscrapeimages.vb

📁 VB.NET的Web浏览器IE7的克隆选项卡式浏览器 描述:这是一个例子写的vb.net浏览器使用的。 NET Framework 2.0 ( Visual Studio 2005中) 。这是一个
💻 VB
字号:
Imports System.IO
Public Class frmScrapeImages

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.Close()
    End Sub

    Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
        'Don't really care if this fails due to some fluke, 
        'Want the process to continue and grab as many images as it can.
        On Error Resume Next
        If txtPath.Text = String.Empty Then
            MessageBox.Show("Please select a folder to save the images to", _
            "Select Folder", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Exit Sub
        End If
        If Not Directory.Exists(txtPath.Text) Then
            MessageBox.Show("Please select a valid directory.", _
            "Select Folder", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Exit Sub
        End If

        btnStart.Enabled = False
        btnCancel.Enabled = False
        Dim oDoc As HtmlDocument = AppManager.CurrentBrowser.Document
        pBar.Visible = True
        pBar.Maximum = oDoc.Images.Count
        Dim oImage As Image

        Dim i As Integer
        For i = 0 To oDoc.Images.Count - 1
            oImage = AppManager.GetWebImage(oDoc.Images(i).GetAttribute("src"))
            If Not IsNothing(oImage) Then
                Dim ofile() As String = Split(oDoc.Images(i).GetAttribute("src"), "/")
                oImage.Save(txtPath.Text & "\Image" & i & ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
                lblStatus.Text = "Saving " & ofile(UBound(ofile)).ToString & "..."
            End If
            pBar.Value = i
            Application.DoEvents()
            oImage = Nothing
        Next

        If chkOpen.Checked = True Then
            'Even though we already checked... we'll check again just to be safe.
            If Directory.Exists(txtPath.Text) Then
                Process.Start(txtPath.Text)
            End If
        End If

        Me.Close()
    End Sub

    Private Sub btnPath_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPath.Click
        Dim fbd As New FolderBrowserDialog
        fbd.ShowDialog()
        txtPath.Text = fbd.SelectedPath
    End Sub

End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -