[C#] 纯文本查看 复制代码 namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
       public  string cookie = "";
        //创建HTTP访问类对象
        HttpHelper http = new HttpHelper();
        HttpItem item = null;
        public static string URLDecode(string text)
        {
            return HttpUtility.UrlDecode(text, Encoding.GetEncoding("utf-8"));
        }
        public static string URLEncode(string text)
        {
            return HttpUtility.UrlEncode(text, Encoding.GetEncoding("utf-8"));
        }
      
        private void button3_Click(object sender, EventArgs e)  // 测试正常
        {
             HttpHelper http = new HttpHelper();
            HttpItem item = new HttpItem()
            {
                URL = "http://passport1.china.com/user/passportLogon.do?username=%E4%B8%AD%E5%9B%BD%E9%A6%96%E9%A2%862011&password=123456&cookietime=-1&cookietime=-1&callback=china_api_login_login.callback",//URL     必需项  
                Method = "GET",//URL     可选项 默认为Get  
                Timeout = 100000,//连接超时时间     可选项默认为100000  
                ReadWriteTimeout = 30000,//写入Post数据超时时间     可选项默认为30000  
                IsToLower = false,//得到的HTML代码是否转成小写     可选项默认转小写  
                Cookie = "",//字符串Cookie     可选项  
                UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; BOIE9;ZHCN)",//用户的浏览器类型,版本,操作系统     可选项有默认值  
                Accept = "application/javascript, */*;q=0.8",//    可选项有默认值  
                ContentType = " text/html; charset=UTF-8",//返回类型    可选项有默认值  
           //     Postdata = "formhash=77009dc2&referer=http%3A%2F%2Fwww.i0532.net%2Findex.php&loginfield=username&username=%B4%F3%BC%D2%BA%C3&password=wqjihqtqk&questionid=0&answer=",//Post数据     可选项GET时不需要写  
                Allowautoredirect = false
            };
            HttpResult result = http.GetHtml(item);
            string html = result.Html;
             cookie = result.Cookie;
           //  webBrowser1.DocumentText += html;
             richTextBox2.Text = html;
            //登录成功后进行测试
            item = new HttpItem()
            {
                URL = "http://club.china.com/data/threads/1011",//URL   
                Method = "get",//URL     可选项 默认为Get
                Cookie = cookie//当前登录Cookie
            };
            //得到HTML代码
             result = http.GetHtml(item);
            string  html2 = result.Html; 
             cookie = result.Cookie;
             richTextBox1.Text = html2;
             webBrowser1.DocumentText = richTextBox1.Text;
        }
    }
 
 
=================================================== 
 
   飞哥帮忙看看!!!谢谢啊 
 
 |