日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

從Internet上抓取指定URL的源碼的方案(C#)(3)_.Net教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:ASP.NET對IIS中的虛擬目錄進(jìn)行操作
//假如虛擬目錄名為"Webtest",先在項目中引用 //System.DirectoryServices.dll,再 using System.DirectoryServices; protected System.DirectoryServices.DirectoryEntry di

/// <summary>
/// 輸出文件路徑
/// </summary>
public string OutFilePath
{
get{return outFilePath;}
set{outFilePath=value;}
}
/// <summary>
/// 返回的字符串
/// </summary>
public string OutString
{
get{return outString;}

}
/// <summary>
/// 返回提示信息
/// </summary>
public string NoteMessage
{
get{return noteMessage;}

}

#endregion

#region 構(gòu)造函數(shù)
public GetPageCode()
{
}
#endregion

#region 公共方法
/// <summary>
/// 讀取指定URL地址,存到指定文件中
/// </summary>
public void GetSource()
{
WebRequest request = WebRequest.Create(this.url);
//使用代理服務(wù)器的處理
if(this.proxyState==1)
{
//默認(rèn)讀取80端口的數(shù)據(jù)
if(this.proxyPort==null)
this.ProxyPort="80";

WebProxy myProxy=new WebProxy();
myProxy = (WebProxy)request.Proxy;
myProxy.Address = new Uri(this.ProxyAddress ":" this.ProxyPort);
myProxy.Credentials = new NetworkCredential(this.proxyAccount, this.proxyPassword, this.ProxyDomain);
request.Proxy = myProxy;
}
try

{
//請求服務(wù)
WebResponse response = request.GetResponse();
//返回信息
Stream resStream = response.GetResponseStream();
StreamReader sr = new StreamReader(resStream, System.Text.Encoding.Default);
string tempCode= sr.ReadToEnd();
resStream.Close();
sr.Close();

//如果輸出文件路徑為空,便將得到的內(nèi)容賦給OutString屬性
if(this.outFilePath==null)
{
this.outString=tempCode;
}
else
{

FileInfo fi = new FileInfo(this.outFilePath);
//如果存在文件則先干掉
if(fi.Exists)
fi.Delete();

StreamWriter sw = new StreamWriter(this.outFilePath,true,Encoding.Default);
sw.Write(tempCode);
sw.Flush();
sw.Close();
}
}
catch
{
this.noteMessage="出錯了,請檢查網(wǎng)絡(luò)是否連通;";
}


}
#endregion
}
}

分享:ASP.NET中數(shù)據(jù)庫的操作初步----增加、刪除、修改
注意:本文暫時不講解數(shù)據(jù)庫的數(shù)據(jù)調(diào)出和顯示,因為他涉及的東西比較多,所以我們將另外詳細(xì)講解。本文主要要講的是數(shù)據(jù)庫的增加、刪除、修改。 一、定義OleDbCommand類型變量:MyCommand

共3頁上一頁123下一頁
來源:模板無憂//所屬分類:.Net教程/更新時間:2008-08-22
相關(guān).Net教程