コード例 #1
0
        /// <summary>
        /// 获取收藏总数
        /// </summary>
        /// <returns>收藏总数</returns>
        private int Init()
        {
            string str = HttpRequst.GetHtmls(constr.GetAddress(1), "", cookie);

            writeStringToFile(str, 1);
            int i = str.IndexOf("count-badge");

            str = str.Substring(i + 13, 100);
            int Count = 0;

            foreach (var c in str)
            {
                if (c <= 57 && c >= 48)
                {
                    Count++;
                }
                else
                {
                    break;
                }
            }
            try
            {
                return(int.Parse(str.Substring(0, Count)));
            }
            catch (Exception ex)
            {
                Console.WriteLine("错误:" + ex.Message + ",检查Cookie是否正确");
                return(0);
            }
        }
コード例 #2
0
        /// <summary>
        /// 多线程数据处理
        /// </summary>
        private void Pross()
        {
            int i;

            while (true)
            {
                lock (samp)
                {
                    if (PageCount == 0)
                    {
                        break;
                    }
                    i = PageCount;
                    PageCount--;
                }
                string str = HttpRequst.GetHtmls(constr.GetAddress(i), "", cookie);
                //File.WriteAllText("Z:\\Test" + i.ToString() + ".html", str);//保存下载到的网页数据
                Indexs[i - 1] = HttpRequst.SearchInHtmlFile(str, i);
            }
        }