Beispiel #1
0
        public void ParseCookie()
        {
            HttpHeader header = new HttpHeader();
            HTMLHelper html = new HTMLHelper();
            string url = "http://m.fang.com/my/?c=mycenter&a=index&city=bj";
            url = "https://m.fang.com/passport/login.aspx";
            //url = "http://m.fang.com";
            //url = "http://m.fang.com/my/";
            //header.method = "get";
            //header.contentType = "text/html";

            //var cookie = HTMLHelper.GetCookie(url,string.Empty,header);

            header = new HttpHeader();
            header.accept = "text/html, application/xhtml+xml, */*";
            header.contentType = "application/x-www-form-urlencoded; charset=GBK";
            header.method = "POST";
            //header.userAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0";
            header.maxTry = 3;

            string postParam = "username=17701000011&password=451426&backurl=http://m.fang.com/";

            var uri = new Uri(url);
            var cc = HTMLHelper.GetCookie(url, postParam, header, "gbk");
            var cookie = cc.GetCookies(uri);
            var list = HTMLHelper.GetAllCookies(cc).FirstOrDefault();
            var hcontent = HTMLHelper.GetHtml("http://m.fang.com/my/?c=mycenter&a=index&city=bj", cc, header, "gbk");
        }
Beispiel #2
0
        /// <summary>
        /// 访问博客园
        /// </summary>
        public void ParseCnBlogCookie()
        {
            HttpHeader header = new HttpHeader();
            HTMLHelper html = new HTMLHelper();
            string url = string.Empty;
            url = "http://passport.cnblogs.com/user/signin";

            header = new HttpHeader();
            header.accept = "text/html, application/xhtml+xml, */*";
            header.contentType = "application/x-www-form-urlencoded; charset=UTF-8";
            header.method = "POST";
            //header.userAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0";
            header.maxTry = 3;

            string postParam = "username=*****&password=*******&backurl=http://home.cnblogs.com/u/allenstar/";

            var uri = new Uri(url);
            var cc = HTMLHelper.GetCookie(url, postParam, header);
            var cookie = cc.GetCookies(uri);
            var list = HTMLHelper.GetAllCookies(cc);
            var hcontent = HTMLHelper.GetHtml("http://home.cnblogs.com/u/allenstar/", cc, header);
        }