利用WebClient和WebRequest类获得网页源代码
2007-11-29 22:21
405 查看
关键是ValidateRequest="false",要不然会说request.form,报错
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div align="center" style="FONT-WEIGHT: bold">得到任意网页源代码</div>
<asp:TextBox id="UrlText" runat="server" Width="400px">http://boco.com.cn
</asp:TextBox>
<asp:Button id="WebClientButton" Runat="server" Text="用WebClient得到" OnClick="WebClientButton_Click"></asp:Button>
<asp:Button id="WebRequestButton" runat="server" Text="用WebRequest得到" OnClick="WebRequestButton_Click"></asp:Button>
<asp:Button ID="Button1" runat="server" OnClick="GetText_Click" Text="Button" /><br>
<asp:TextBox id="ContentHtml" runat="server" Width="100%" Height="360px" TextMode="MultiLine">
</asp:TextBox>
</form>
</body>
</html>
private string PageUrl = "";
protected void WebClientButton_Click(object sender, System.EventArgs e)
protected void WebRequestButton_Click(object sender, System.EventArgs e)
protected void GetText_Click(object sender, System.EventArgs e)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div align="center" style="FONT-WEIGHT: bold">得到任意网页源代码</div>
<asp:TextBox id="UrlText" runat="server" Width="400px">http://boco.com.cn
</asp:TextBox>
<asp:Button id="WebClientButton" Runat="server" Text="用WebClient得到" OnClick="WebClientButton_Click"></asp:Button>
<asp:Button id="WebRequestButton" runat="server" Text="用WebRequest得到" OnClick="WebRequestButton_Click"></asp:Button>
<asp:Button ID="Button1" runat="server" OnClick="GetText_Click" Text="Button" /><br>
<asp:TextBox id="ContentHtml" runat="server" Width="100%" Height="360px" TextMode="MultiLine">
</asp:TextBox>
</form>
</body>
</html>
private string PageUrl = "";
protected void WebClientButton_Click(object sender, System.EventArgs e)
protected void WebRequestButton_Click(object sender, System.EventArgs e)
protected void GetText_Click(object sender, System.EventArgs e)
相关文章推荐
- 利用WebClient和WebRequest类获得网页源代码C#
- [ASP.NET]c#利用WebClient和WebRequest类获得网页源代码
- 利用WebClient和WebRequest类获得网页源代码C#
- 利用WebClient和WebRequest类获得网页源代码C#
- 利用WebClient和HttpWebRequest类获得网页源代码
- 利用WebClient和WebRequest类获得网页源代码
- 利用WebClient和WebRequest类获得网页源代码
- 利用WebClient和WebRequest类获得网页源代码
- 利用WebClient和WebRequest类获得网页源代码
- 利用WebClient和WebRequest类获得网页源代码
- 利用WebClient和WebRequest类获得网页源代码
- 利用WebClient和WebRequest类获得网页源代码
- [转帖]利用WebClient和WebRequest类获得网页源代码
- 利用WebClient和WebRequest类获得网页源代码
- 利用WebClient和WebRequest类获得网页源代码http://dotnet.aspx.cc/article/0a6660ce-4138-41ef-b882-15db65564709/read.aspx
- 利用WebClient和WebRequest类获得网页源代码
- 利用WebClient和WebRequest类获得网页源代码
- 利用WebClient和WebRequest类获得网页源代码
- 利用WebClient和WebRequest类获得网页源代码
- 得到任意网页源代码 (利用WebClient和WebRequest类)