Web Page Snapshots

brent

New member
Joined
Aug 5, 2011
Messages
4
Programming Experience
1-3
I have written an application which extracts a list of URL's (currently in
Internet Explorer cache) from an XML file and displays them in a data grid view.
From here i would like to launch Internet Explorer in a hidden mode and capture
an image for each of the selected URL's in the data grid view. Is this possbile?
If so what is the best way to go about it? Or does anybody have any other
suggestions on other ways i could recieve the same result?

Thanks
 
Thanks for the reply. I should have been a bit clearer in my above post. currently i am looping through my data grid view of URL's opening the selected URL's (eg Google) in Internet Explorer taking a snapshot of them and then saving a copy of the image. The problems with what i have are as follows:

1) When taking the snapshot it only captures what is on the screen (it does not show the entire web page as it is unable to scroll to the bottom of the page)

2) I would like the whole process to be hidden

Here is a snippet of my code showing what my application currently does:

VB.NET:
 Dim name As String = ""
        For Each rows As DataGridViewRow In DataGridView3.Rows
            If Convert.ToBoolean(DirectCast(rows.Cells(0), DataGridViewCheckBoxCell).Value) = True Then

                'Put Internet Explorer into 'Offline Mode'
                My.Computer.Registry.SetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "GlobalUserOffline", "1", Microsoft.Win32.RegistryValueKind.DWord)

                Dim value As New Object
                value = rows.Cells(2).Value.ToString
                If value = Nothing Then
                    ' Do Nothing because row is empty
                Else

                    Dim IE As New InternetExplorer
                    IE.Visible = True
                    IE.Navigate(value)
                    IE.Offline = True
                    IE.FullScreen = True
                    System.Threading.Thread.Sleep(2000)

                    Dim width As Integer, height As Integer
                    width = IE.Width
                    height = IE.Height
                    Using image As New Bitmap(width, height)
                        Using graphics__1 As Graphics = Graphics.FromImage(image)
                            Dim p As Point, upperLeftSource As Point, upperLeftDestination As Point
                            p = New Point(0, 0)
                            upperLeftSource = New Point(0, 0)
                            upperLeftDestination = New Point(0, 0)
                            Dim blockRegionSize As Size = New Size(width, height)

                            graphics__1.CopyFromScreen(upperLeftSource, upperLeftDestination, blockRegionSize)

                        End Using

                        name = rows.Cells(2).Value
                        'Remove http://, https://, www.
                        Dim name2 As String = name.Replace("http://", " ")
                        name2 = name2.Replace("https://", " ")
                        name2 = name2.Replace("www.", " ")

                        'Replace all illegal file name characters from the URL and replace with "_"
                        name2 = name2.Replace("?", "_")
                        name2 = name2.Replace("/", "_")
                        name2 = name2.Replace(":", "_")
                        name2 = name2.Replace("*", "_")
                        name2 = name2.Replace("?", "_")
                        name2 = name2.Replace(":", "_")
                        name2 = name2.Replace("<", "_")
                        name2 = name2.Replace(">", "_")
                        name2 = name2.Replace("|", "_")

                        Dim character As String
                        Dim name3 As String = ""
                        Dim i As Integer = 0
                        Dim MaxFilePath As Integer = 253 - Form4.PathToimages.Length
                        Do While i <= MaxFilePath
                            If name2.Length > i Then
                                character = name2.Chars(i)
                                name3 = name3 + character
                                i = i + 1
                            Else
                                Exit Do
                            End If
                        Loop
                        image.Save(Form4.PathToimages + "\" + name3 + ".bmp")

                    End Using
                    System.Threading.Thread.Sleep(1000)

                    IE.Quit()

                End If
            End If
        Next

The reason i put Internet Explorer into offline mode is that all pages i wish to view are currently in cache and i do not want to download any active content.

Does anybody have any ideas on how i could achieve a similar result with the whole process being hidden?

Thanks,
Brent
 
Back
Top