| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 574 人关注过本帖
标题:登陆网站的代码问题~~急~!
只看楼主 加入收藏
wanghaotong
Rank: 1
等 级:新手上路
帖 子:47
专家分:0
注 册:2009-3-6
结帖率:76.47%
收藏
 问题点数:0 回复次数:0 
登陆网站的代码问题~~急~!
public static byte[] GetHtmlByBytes(string server, string URL, byte[] byteRequest, string cookie,out string header)
        {
            long contentLength;
            HttpWebRequest httpWebRequest;
            HttpWebResponse webResponse;
            Stream getStream;

            httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(URL);
            CookieContainer co = new CookieContainer();
            co.SetCookies(new Uri(server), cookie);

            httpWebRequest.CookieContainer = co;

            httpWebRequest.ContentType = "application/x-www-form-urlencoded";
            httpWebRequest.Accept = "*/*";
            httpWebRequest.Referer = "http://china.
            httpWebRequest.UserAgent =
                "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Maxthon 2.0)";
            httpWebRequest.Method = "Post";
            httpWebRequest.ContentLength = byteRequest.Length;
            Stream stream;
            stream = httpWebRequest.GetRequestStream();
            stream.Write(byteRequest, 0, byteRequest.Length);
            stream.Close();
            webResponse = (HttpWebResponse)httpWebRequest.GetResponse();
            header = webResponse.Headers.ToString();
            getStream = webResponse.GetResponseStream();
            contentLength = webResponse.ContentLength;

            byte[] outBytes = new byte[contentLength];  //在这提示算术运算导致溢出的错误...怎么解决?
            outBytes = ReadFully(getStream);
            getStream.Close();
            return outBytes;
        }
有没有高手有更好的方法!!!!!!!!
搜索更多相关主题的帖子: 登陆 代码 
2010-02-20 14:57
快速回复:登陆网站的代码问题~~急~!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015836 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved