1
我有一个奇怪的问题,我采取单词的列表,并通过做谷歌搜索字创建屏幕截图.. 它创建像50个屏幕截图后,它开始创建空白图像!创建缩略图失败,并创建空白图像
有人可以帮我解决这个问题!
PS:让我知道,如果我需要更清晰!
这是我用来创建屏幕截图的代码...在我的主页上,我只是循环上我的话!
有人可以帮我解决这个问题
public class GeneateScreenshot
{
public void GenerateScreenshot()
{
}
public Bitmap GenerateScreenshot(string url)
{
// This method gets a screenshot of the webpage
// rendered at its full size (height and width)
return GenerateScreenshot(url, -1, -1);
}
public Bitmap GenerateScreenshot(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;
}
}
有多快被这个循环通过? Google不喜欢自动查询,如果您自己收到空白网页,我不会感到惊讶。我建议可能每隔几次加载就会保存网页浏览器控件的结果HTML,并查看HTML是否在某个时刻剧烈变化。 – MindingData
像7-8分钟100个问题! – helpme