.NET获取网页源代码

xiaoxiao2022-06-22  51

using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.IO; using System.Net; using System.Text; public partial class Thief : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string url = "http://www.myspace.cn/"; //要获取的网页地址 WebRequest req = WebRequest.Create(url); WebResponse res = req.GetResponse(); Stream resStream = res.GetResponseStream(); StreamReader sr = new StreamReader(resStream, Encoding.UTF8); string contentHTML = sr.ReadToEnd(); //读取网页的源代码 Response.Write(contentHTML); resStream.Close(); sr.Close(); } }

 

转载请注明原文地址: https://www.6miu.com/read-4951161.html

最新回复(0)