#region GET
/// <summary>
/// GET
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
public static string getPage(String url)
{
WebResponse result = null;
string txthtml=string.Empty;
try
{
WebRequest req = WebRequest.Create(url);
result = req.GetResponse();
Stream ReceiveStream = result.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("gb2312");
StreamReader sr = new StreamReader(ReceiveStream,encode);
//this.Message.Text+="\r\n已接收到响应流";
if (true)
{
Char[] read = new Char[256];
int count = sr.Read( read, 0, 256 ); // this.Message.Text+="HTML...\r\n";
while (count > 0)
{
String str = new String(read, 0, count);
txthtml+=str;
count = sr.Read(read, 0, 256);
}
// this.Message.Text="":
}
}
catch(Exception)
{
txthtml="err";
//this.is_id.Value=url;
}
finally
{
if (result != null)
{
result.Close();
}
}
//this.is_id.Value=url;
return txthtml;
} #endregion
/// <summary>
/// GET
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
public static string getPage(String url)
{
WebResponse result = null;
string txthtml=string.Empty;
try
{
WebRequest req = WebRequest.Create(url);
result = req.GetResponse();
Stream ReceiveStream = result.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("gb2312");
StreamReader sr = new StreamReader(ReceiveStream,encode);
//this.Message.Text+="\r\n已接收到响应流";
if (true)
{
Char[] read = new Char[256];
int count = sr.Read( read, 0, 256 ); // this.Message.Text+="HTML...\r\n";
while (count > 0)
{
String str = new String(read, 0, count);
txthtml+=str;
count = sr.Read(read, 0, 256);
}
// this.Message.Text="":
}
}
catch(Exception)
{
txthtml="err";
//this.is_id.Value=url;
}
finally
{
if (result != null)
{
result.Close();
}
}
//this.is_id.Value=url;
return txthtml;
} #endregion
解决方案 »
- SharpPcap 流量问题
- 本人想开发一个C/S的或者B/S的信息采集系统该怎么做?
- 启动系统服务问题
- gradview问题
- 关于C#调用外部动态库的问题,急!
- 求助delphi翻译为C#中struct的问题!
- spread 的问题,custom celltype 请使用过的同仁帮帮忙!!!!!
- 刚学asp.net的,怎么获得datagrid里面的textbox的值,急,解决问题的把100都给大家
- 有没有办法得到WINDOWS2000中的[组]和[用户]列表?
- 对注册表项 HKEY_CLASSES_ROOT\logistics.BusinessRules.Wharehouse 的访问被拒绝。
- 窗体重绘的一个问题(C#下)
- 在datagridColumnStyle集合编辑器的添加按钮里如何加入自己做的Column类型
http://www.430000.net/printpage.asp?ArticleID=69