Access Internet

原创 2007年09月28日 13:58:00


        //要请求的url
        public string requesturi = "http://search.51job.com/jobsearch/search_result.php";
        //要发送的请求
        public System.Net.HttpWebRequest webrequest;
        //要收到的响应
        public System.Net.HttpWebResponse webreponse;
        //要发送的 cookie
        public CookieCollection cookies = null;
        //send request
        //第一次发送请求,根据工作地点,职位发布日期,职位关键字 得到具体职位的信息
        private ArrayList sendRequest(string jobarea, int issuedate, string keyword)
        {
            #region  准备发送数据
            System.Text.StringBuilder builder = new StringBuilder();
            //构造将要发送的数据
            //工作地点
            builder.Append("postchannel=0000&stype=0&jobarea=" + jobarea);
            //职位发布日期
            builder.Append("&funtype_big=0100&funtype=0100&industrytype=&issuedate=" + issuedate);
            //职位关键字
            builder.Append( "&keywordtype=2&keyword=" + keyword);
            builder.Append( "&curr_page=1");
            //把发送的数据转换成字节
            byte[] sendbyte = System.Text.Encoding.Default.GetBytes(builder.ToString());
           

            //构造一个请求
            System.Net.HttpWebRequest webrequest = System.Net.WebRequest.Create(requesturi) as System.Net.HttpWebRequest;
            //设置发送请求的提交方式
            webrequest.Method = "post";
            //设置HttpReferer 标头
            webrequest.Referer = "http://search.51job.com/jobsearch/default_search.php";
            //设置发送的数据类型
            webrequest.ContentType = "application/x-www-form-urlencoded";
            //设置发送请求数据的长度
            webrequest.ContentLength = sendbyte.Length;
            //添加 cookie
            if (cookies != null)
            {
                webrequest.CookieContainer = new System.Net.CookieContainer();
                webrequest.CookieContainer.Add(cookies);
            }        
            System.IO.Stream postData = webrequest.GetRequestStream();
            postData.Write(sendbyte, 0, sendbyte.Length);
            postData.Close();
            #endregion
            //receive response
            webreponse = webrequest.GetResponse() as System.Net.HttpWebResponse;

            cookies = webreponse.Cookies;

            System.IO.Stream stream = webreponse.GetResponseStream();
            System.IO.StreamReader reader = new System.IO.StreamReader(stream, System.Text.Encoding.GetEncoding("gb2312"));
            System.Text.StringBuilder sbuilder = new StringBuilder();
            sbuilder.Append(reader.ReadToEnd()); 

版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

Android客户端和Internet的交互

在Android中所集成的HttpClient是(org.apache.http.*) Android 实现Post向服务器提交数据 熟悉web编程的都很了解get和post这两种传递表单数据的方...

icould bookmarks sync problem with Internet Explorer

Problem: Icould cannot sync bookmarks with Internet Explorer OS: Windows 7 Icould Control Panel: 1...

POJ 3911:Internet Service Providers

Internet Service Providers Time Limit: 2MS   Memory Limit: 65536KB   64bit IO Format: %...

Internet类故障

一、定义举例主要是与浏览Internet有关的软、硬件故障。如:不能拨号、不能浏览网页等。二、可能的故障现象1、不能拨号、无拨号音、拨号有杂音、上网掉线;2、上网速度慢、个别网页不能浏览;3、上网时死...

TCP,IP详解,卷一:协议学习笔记之第六章 ICMP: Internet控制报文协议

 1,ICMP报文是在IP数据报内部被传输的,如图6-1所示: 2,ICMP报文前4个字节都是一样的,但是剩下的其他字节则互不相同,其格式如图6-2所示: 3,一份ICM...

《The 3G IP MultiMedia Subsystem -- merging the INTERNET and the cellular worlds》

the IMS is to offer Internet services everywhere and at any time using cellular technologies. IMS使用无...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)