/// <summary>
        /// 得到网页内容
        /// </summary>
        /// <param name="nextUrl"></param>
        /// <param name="postData"></param>
        /// <param name="cookies"></param>
        /// <param name="currentUrl"></param>
        /// <returns></returns>
        protected override string GetMainWebContent(string nextUrl, byte[] postData, ref string cookies, string currentUrl)
        {
            HttpHelper httpHelper = new HttpHelper
            {
                UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.108 Safari/537.36 2345Explorer/8.6.2.15784",
                Cookies   = _cookies
            };
            var webContent = httpHelper.GetHtmlByGet(nextUrl);

            //var webContent = base.GetMainWebContent(nextUrl, postData, ref _cookies, currentUrl);

            if (!Regex.Match(webContent, "^window.location.href='.*';").Success)
            {
                return(webContent);
            }



            Console.WriteLine(@"解析验证码中...................");
            bool isSuccess = false;
            int  i         = 1;

            while (isSuccess == false)
            {
                Console.WriteLine($"第{i}次解析验证码");
                TesseractDemo tesseract = new TesseractDemo();
                if ((isSuccess = tesseract.HandleValidateCode()) == false)
                {
                    i++;
                }
            }

            return(base.GetMainWebContent(nextUrl, postData, ref _cookies, currentUrl));
        }
Exemplo n.º 2
0
        public bool CheckUserCode(string htmlStringContent)
        {
            const string shielded = "\"remind\"";

            if (htmlStringContent.Equals(shielded))
            {
                Console.WriteLine(@"解析验证码中...................");
                bool isSuccess = false;
                int  i         = 1;
                while (isSuccess == false)
                {
                    Console.WriteLine($"第{i}次解析验证码");
                    TesseractDemo tesseract = new TesseractDemo();
                    if ((isSuccess = tesseract.HandleValidateCode()) == false)
                    {
                        i++;
                    }
                }

                /*GetCourtTree1(caseType, level, key, span);
                 * return;*/
                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 处理验证码
        /// </summary>
        public void LoopHandleValidateCode()
        {
            Console.WriteLine(@"解析验证码中...................");
            bool isSuccess = false;
            int  i         = 1;

            while (isSuccess == false)
            {
                Console.WriteLine($"第{i}次解析验证码");
                TesseractDemo tesseract = new TesseractDemo();
                if ((isSuccess = tesseract.HandleValidateCode()) == false)
                {
                    i++;
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 得到案由搜索树
        /// </summary>
        /// <param name="caseType"></param>
        /// <param name="level"></param>
        /// <param name="key"></param>
        /// <param name="span"></param>
        public void GetReasonTree(string caseType, string level, string key, int span = 0)
        {
            //Console.WriteLine($"{new string(' ', span * 2)} {caseType} # {level} # {key}");

            var htmlString = GetHtmlFromPost(@"http://wenshu.court.gov.cn/List/ReasonTreeContent", Encoding.UTF8, $"Param=案件类型:{caseType},{level}:{key}&parval={key}");

            if (htmlString.Equals(string.Empty))
            {
                Console.WriteLine($"{caseType} # {key} # {level}(自己查)");
            }
            const string shielded = "\"remind\"";

            if (htmlString.Equals(shielded))
            {
                Console.WriteLine(@"解析验证码中...................");
                bool isSuccess = false;
                int  i         = 1;
                while (isSuccess == false)
                {
                    Console.WriteLine($"第{i}次解析验证码");
                    TesseractDemo tesseract = new TesseractDemo();
                    if ((isSuccess = tesseract.HandleValidateCode()) == false)
                    {
                        i++;
                    }
                }
                GetReasonTree(caseType, level, key, span);
                return;
            }

            var dics = GetSearchTreeKey(htmlString);

            if (dics.Count == 0)
            {
                var          postData          = $"Param=案件类型:{caseType},{level}:{key}&Index=1&Page=20&Order=裁判日期&Direction=asc";
                const string url               = "http://wenshu.court.gov.cn/List/ListContent";
                var          htmlStringContent = GetHtmlFromPost(url, Encoding.UTF8, postData);
                if (htmlStringContent.Equals(shielded))
                {
                    Console.WriteLine(@"解析验证码中...................");
                    bool isSuccess = false;
                    int  i         = 1;
                    while (isSuccess == false)
                    {
                        Console.WriteLine($"第{i}次解析验证码");
                        TesseractDemo tesseract = new TesseractDemo();
                        if ((isSuccess = tesseract.HandleValidateCode()) == false)
                        {
                            i++;
                        }
                    }
                    GetReasonTree(caseType, level, key, span);
                    return;
                }

                var num = GetTotalPages(htmlStringContent);
                Console.WriteLine($"{caseType} # {key} # {level}({num})");
                return;
            }

            foreach (var dic in dics)
            {
                if (dic.Key.Equals("人事争议") && dic.Value.Equals("四级案由"))
                {
                    Console.WriteLine($"{caseType} # {dic.Key} # {dic.Value}(手动查)");
                }
                else
                {
                    GetReasonTree(caseType, dic.Value, dic.Key, span + 1);
                }
            }
        }