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