- 积分
 - 40186
 
- 好友
  
- 记录
  
- 主题
  
- 帖子
  
- 听众
  
- 收听
  
 
 
 
 
 
 | 
 
 
发表于 2013-5-15 22:22:34
|
显示全部楼层
 
 
 
[code=csharp]  HttpHelper http = new HttpHelper(); 
            HttpItem item = new HttpItem() 
            { 
                URL = "http://www.harcw.cn/login.asp",//URL这里都是测试URl   必需项 
                //Encoding = null,//编码格式(utf-8,gb2312,gbk)     可选项 默认类会自动识别 
                Encoding = Encoding.Default, 
                Method = "post",//URL     可选项 默认为Get 
                ContentType="application/x-www-form-urlencoded", 
                Postdata = "usertype=personal&username=maple&password=maple1234" 
            }; 
       
            //得到HTML代码 
            HttpResult result = http.GetHtml(item); 
             http = new HttpHelper(); 
             item = new HttpItem() 
            { 
                URL = " http://www.harcw.cn/area_pers/user.asp",//URL这里都是测试URl   必需项 
                //Encoding = null,//编码格式(utf-8,gb2312,gbk)     可选项 默认类会自动识别 
                Encoding = Encoding.Default, 
                Method = "get",//URL     可选项 默认为Get 
                Cookie=result.Cookie                
            }; 
       
            //得到HTML代码 
             result = http.GetHtml(item);[/code] 
这样写就可以登录了 
不是所有的Post都可以与Get相互转化,这个要看服务端有没有限制,具体的看文章吧 
http://www.sufeinet.com/forum.php?mod=viewthread&tid=2630 
 
 |   
 
 
 
 |