Asp.Net獲取網(wǎng)站截圖的實(shí)例代碼
更新時(shí)間:2013年07月25日 10:50:25 作者:
這篇文章介紹了Asp.Net獲取網(wǎng)站截圖的實(shí)例代碼,有需要的朋友可以參考一下
復(fù)制代碼 代碼如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private WebBrowser _webBrowser;
public Form1()
{
InitializeComponent();
}
public void GetThumbNail(string url)
{
_webBrowser = new WebBrowser();
_webBrowser.ScrollBarsEnabled = false; //不顯示滾動(dòng)條
_webBrowser.Navigate(url);
_webBrowser.DocumentCompleted = new WebBrowserDocumentCompletedEventHandler(Completed);
while (_webBrowser.ReadyState != WebBrowserReadyState.Complete)
{
System.Windows.Forms.Application.DoEvents(); //避免假死,若去掉則可能無(wú)法觸發(fā) DocumentCompleted 事件。
}
}
public void Completed(object sender, WebBrowserDocumentCompletedEventArgs e)
{
//設(shè)置瀏覽器寬度、高度為文檔寬度、高度,以便截取整個(gè)網(wǎng)頁(yè)。
_webBrowser.Width = _webBrowser.Document.Body.ScrollRectangle.Width;
_webBrowser.Height = _webBrowser.Document.Body.ScrollRectangle.Height;
using (Bitmap bmp = new Bitmap(_webBrowser.Width, _webBrowser.Height))
{
_webBrowser.DrawToBitmap(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height));
bmp.Save("Capture.png", System.Drawing.Imaging.ImageFormat.Png);
pictureBox1.ImageLocation = "Capture.png";
}
}
private void button1_Click(object sender, EventArgs e)
{
GetThumbNail(textBox1.Text);
}
}
}
相關(guān)文章
GridView中checkbox"全選/取消"完美兼容IE和Firefox
GridView中checkbox的的"全選/取消"使用還是比較頻繁的,本文有個(gè)不錯(cuò)的示例完美兼容IE和Firefox,感興趣的朋友可以參考下,希望對(duì)大家有所幫助2013-10-10
asp.net ajaxControlToolkit FilteredTextBoxExtender的簡(jiǎn)單用法
最近寫(xiě)的東西驗(yàn)證比較多,尤其是數(shù)字驗(yàn)證,無(wú)意中發(fā)現(xiàn)這個(gè)控件,有點(diǎn)兒意思。記錄一下2008-11-11
Silverlight4 多語(yǔ)言實(shí)現(xiàn)的方法
這篇文章介紹了Silverlight4 多語(yǔ)言實(shí)現(xiàn)的方法,有需要的朋友可以參考一下2013-10-10
ASP.NET動(dòng)態(tài)生成靜態(tài)頁(yè)面的實(shí)例代碼
生成靜態(tài)頁(yè)有很多好處,可以緩解服務(wù)器壓力、方便搜索網(wǎng)站搜索等等,下面介紹一下生成靜態(tài)頁(yè)的實(shí)例代碼,有需要的朋友可以參考一下2013-07-07
asp.net部署到IIS常見(jiàn)問(wèn)題的解決方法
這篇文章主要為大家詳細(xì)介紹了asp.net部署到IIS常見(jiàn)問(wèn)題的解決方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-12-12
解決VS2012 Express的There was a problem sending the command to
安裝Visual Studio 2012 Express之后,雙擊打開(kāi)web.config文件時(shí)經(jīng)常出現(xiàn)“There was a problem sending the command to the program”的錯(cuò)誤,然后VS2012 Express打開(kāi)了,但web.config文件沒(méi)打開(kāi),需要再次雙擊web.config文件才能打開(kāi)。很是煩人2013-02-02
值得收藏的asp.net基礎(chǔ)學(xué)習(xí)筆記
這篇文章主要分享了一份值得大家收藏的asp.net基礎(chǔ)學(xué)習(xí)筆記,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-09-09
在Linux上使用OpenCvSharp的過(guò)程詳解
在本次項(xiàng)目中,我們成功實(shí)現(xiàn)了在Linux上使用OpenCvSharp,并成功配置了OpenCvSharp依賴(lài)庫(kù),實(shí)現(xiàn)了在.NET 6.0環(huán)境下使用C#語(yǔ)言調(diào)用OpenCvSharp庫(kù),實(shí)現(xiàn)的圖片數(shù)據(jù)的讀取以及圖像色彩轉(zhuǎn)換,并進(jìn)行了圖像展示,感興趣的朋友跟隨小編一起看看吧2024-02-02

