WebBrowser control in .Net can be used to take thumbnail/ Screenshots of websites.
Then use the Bitmap Class to save them locally.
Code snippet shown below:
public Bitmap GenerateThumbnail(string url)
{
//rendered at full size
return GenerateScreenshot(url, -1, -1);
}
public Bitmap GenerateThumbnail(string url, int width, int height)
{
// Load the webpage into a WebBrowser control
WebBrowser wb = new WebBrowser();
wb.ScrollBarsEnabled = false;
wb.ScriptErrorsSuppressed = true;
wb.Navigate(url);
while (wb.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); }
// Set the size of the WebBrowser control
wb.Width = width;
wb.Height = height;
if (width == -1)
{
// Take Screenshot of the web pages full width
wb.Width = wb.Document.Body.ScrollRectangle.Width;
}
if (height == -1)
{
// Take Screenshot of the web pages full height
wb.Height = wb.Document.Body.ScrollRectangle.Height;
}
// Get a Bitmap representation of the webpage as it's rendered in the WebBrowser control
Bitmap bitmap = new Bitmap(wb.Width, wb.Height);
wb.DrawToBitmap(bitmap, new Rectangle(0, 0, wb.Width, wb.Height));
wb.Dispose();
return bitmap;
}
Notes:
// Generate thumbnail of www.devx.com at 1024x768 resolution
Bitmap thumbnail = GenerateThumbnail("http://www.eggheadcafe.com", 1024, 768);
// Generate thumbnail of a www.devx.com at full size
thumbnail = GenerateThumbnail("http://www.eggheadcafe.com");