using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
namespace 博客
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string x = textBox2.Text;
//指定请求
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://"+x+"");
//得到返回
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
//得到流
Stream recStream = response.GetResponseStream();
//编码方式
Encoding gb2312 = Encoding.GetEncoding("gb2312");
//指定转换为gb2312编码
StreamReader sr = new StreamReader(recStream, gb2312);
//以字符串方式得到网页内容
String content = sr.ReadToEnd();
//将网页内容显示在TextBox中
textBox1.Text = content;
}
}
}