程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> JSP編程 >> 關於JSP >> 利用WebClient和WebRequest類獲得網頁源代碼

利用WebClient和WebRequest類獲得網頁源代碼

編輯:關於JSP

GetURLHtml.aspx
<%@ Page language="c#" Codebehind="GetURLHtml.aspx.cs" Src="GetURLHtml.aspx.cs" AutoEventWireup="false" Inherits="Lion.Web.Forum.WebForm1" %>
<HTML>
 <HEAD>
  <title>Lion互動網絡=>利用WebClient和WebRequest類獲得網頁源代碼</title>
  <META http-equiv="Content-Type" content="text/html; charset=gb2312">
 </HEAD>
 <body>
  <form runat="server">
   <asp:TextBox id="UrlText" runat="server" Width="50%">http://www.lionsky.net/mywebsite/index.aspx</asp:TextBox>
   <asp:Button id="Button1" runat="server" Text="用WebClient得到"></asp:Button>&nbsp;
   <asp:Button id="Button2" runat="server" Text="用WebRequest得到"></asp:Button><BR>
   <asp:TextBox id="ContentHtml" runat="server" Width="100%" Height="360px" TextMode="MultiLine"></asp:TextBox>
  </form>
 </body>
</HTML>
GetURLHtml.aspx.Cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace Lion.Web.Forum
{
 /// <summary>
 /// WebForm1 的摘要說明。
 /// </summary>
 public class WebForm1 : System.Web.UI.Page
 {
  protected System.Web.UI.WebControls.TextBox TextBox1;
  protected System.Web.UI.WebControls.Button Button1;
  protected System.Web.UI.WebControls.Button Button2;
  protected System.Web.UI.WebControls.TextBox UrlText;
  protected System.Web.UI.WebControls.TextBox ContentHtml;
  protected System.Web.UI.WebControls.TextBox TextBox2;

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved