捕获网站屏幕截图。 [英] Capture Website screen shot.
本文介绍了捕获网站屏幕截图。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个.aspx页面。在那里我使用ajax更新面板和Timer控件渲染10个不同的报告。现在,我想通过指定URL(www.mysite.com/report.aspx)定期捕获网站内容。我能够做到这一点,但是如果我的页面有一个ajax调用我无法做到这一点。
我尝试了以下内容:
Hi,
I have an .aspx page. In that i render 10 different reports using ajax update panel and Timer control. Now, i would like to capture content of a website on regular interval by specifying the URL(www.mysite.com/report.aspx). I am able to do this, but if my page has an ajax call i am unable to do that.
I tried the following:
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Threading;
using System.Windows.Forms;
class Program
{
[STAThread]
static void Main()
{
int width = 800;
int height = 600;
using (WebBrowser browser = new WebBrowser())
{
browser.Width = width;
browser.Height = height;
browser.ScrollBarsEnabled = true;
// This will be called when the page finishes loading
browser.DocumentCompleted += Program.OnDocumentCompleted;
browser.
browser.Navigate("www.google.com/");
// This prevents the application from exiting until
// Application.Exit is called
Application.Run();
}
}
static void OnDocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
// Now that the page is loaded, save it to a bitmap
WebBrowser browser = (WebBrowser)sender;
using (Graphics graphics = browser.CreateGraphics())
using (Bitmap bitmap = new Bitmap(browser.Width, browser.Height, graphics))
{
Rectangle bounds = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
browser.DrawToBitmap(bitmap, bounds);
bitmap.Save("screenshot.bmp", ImageFormat.Bmp);
}
// Instruct the application to exit
Application.Exit();
}
}
推荐答案
Hello Prasad,
看看使用C#和VB.Net在ASP.Net中捕获截图(快照)网站(网页)的图像 [ ^ ]。
问候,
Hello Prasad,
Have a look at Capture Screenshot (Snapshot) Image of Website (Web Page) in ASP.Net using C# and VB.Net [^].
Regards,
请使用以下网址:
http://stackoverflow.com/问题/ 5049122 / capture-the-screen-using-net [ ^ ]
Please go through with this URL:
http://stackoverflow.com/questions/5049122/capture-the-screen-shot-using-net[^]
>
请仔细阅读以下内容 -
capture-screenshot-snapshot-of-website-webpage-in-csharp [ ^ ]
Capture-Screenshot-Snapshot-Image-of -Website-Web-Page-in-ASPNet- [ ^ ]
这篇关于捕获网站屏幕截图。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文