httprequest 如何抓取页面信息 并打印到页面上
httprequest 如何抓取页面信息 并打印到页面上
--------------------编程问答--------------------
Uri uri;
if (Uri.TryCreate(txtUrl.Text, UriKind.RelativeOrAbsolute, out uri))
{
HttpWebRequest requset = (HttpWebRequest)WebRequest.Create(uri);
HttpWebResponse response = (HttpWebResponse)requset.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
//Encoding encoding = Encoding.GetEncoding(response.ContentEncoding);
Encoding encoding = Encoding.GetEncoding(response.CharacterSet);
StreamReader reader = new StreamReader(response.GetResponseStream(), encoding);
string html = reader.ReadToEnd();//html变量存储的就是网页的内容
reader.Close();
response.Close();
}
}
--------------------编程问答--------------------
不需要登陆的话 1楼这样做没问题
补充:.NET技术 , C#