Пример #1
0
        private List <CaoQunMainItem> GetCaoQunMainItems()
        {
            List <CaoQunMainItem> res = new List <CaoQunMainItem>();
            HttpCore hc = new HttpCore();

            hc.SetUrl(CaoQunUrl);
            string             mainHtml  = hc.GetHtml();
            HtmlNodeCollection mainItems = mainHtml.SelectNodes("//*[@id='ajaxtable']/tbody[1]/tr[@class='tr3 t_one']");

            if (mainItems == null)
            {
                return(new List <CaoQunMainItem>());
            }
            foreach (HtmlNode mainItem in mainItems)
            {
                var an = mainItem.SelectSingleNode("/td[2]/h3/a");

                string infoUrl = "http://ac168.info/bt/" + an.Attributes["href"].Value;
                string title   = an.InnerText;

                CaoQunMainItem temp = new CaoQunMainItem
                {
                    CaoQunDetailItem = new CaoQunDetailItem(),
                    InfoUrl          = infoUrl,
                    Title            = title,
                    Url = CaoQunUrl
                };
                res.Add(temp);
            }
            return(res);
        }
Пример #2
0
        private static void StoreDB(CaoQunMainItem caoQunMainItem)
        {
            DapperHelper dh        = DapperHelper.GetInstance("Data Source=.;Initial Catalog=DeanDB;Integrated Security=True");
            const string sqlFormat =
                @"INSERT INTO [dbo].[WebCrawlerResult]
           ([Title]
           ,[PicDic]
           ,[Url]
           ,[Remark])
     VALUES
           ('{0}'
           ,'{1}'
           ,'{2}'
           ,'{3}')";
            string sql = string.Format(sqlFormat, caoQunMainItem.Title, caoQunMainItem.CaoQunDetailItem.PicDic,
                                       caoQunMainItem.InfoUrl, caoQunMainItem.Remark);

            dh.Execute(sql);
        }
Пример #3
0
        private static void SaveImg(string imgFileName, CaoQunMainItem caoQunMainItem, Image img, string imgUrl)
        {
            try
            {
                caoQunMainItem.CaoQunDetailItem.PicUrl = imgUrl;
                Console.WriteLine(imgUrl);

                if (!Directory.Exists("F://" + imgFileName + "/" + caoQunMainItem.Title + "/"))
                {
                    Directory.CreateDirectory("F://" + imgFileName + "/" + caoQunMainItem.Title + "/");
                }
                string pic = caoQunMainItem.CaoQunDetailItem.PicDic = "F://" + imgFileName + "/" + caoQunMainItem.Title + "/" + imgUrl.Split('/').Last();

                img.Save(pic.Trim('?'));
                img.Dispose();
            }
            catch (Exception)
            {
            }
        }
Пример #4
0
        private static void SaveImg(string imgFileName, CaoQunMainItem caoQunMainItem, Image img, string imgUrl)
        {
            try
            {
                caoQunMainItem.CaoQunDetailItem.PicUrl = imgUrl;
                Console.WriteLine(imgUrl);

                if (!Directory.Exists("F://" + imgFileName + "/" + caoQunMainItem.Title + "/"))
                {
                    Directory.CreateDirectory("F://" + imgFileName + "/" + caoQunMainItem.Title + "/");
                }
                string pic = caoQunMainItem.CaoQunDetailItem.PicDic = "F://" + imgFileName + "/" + caoQunMainItem.Title + "/" + imgUrl.Split('/').Last();

                img.Save(pic.Trim('?'));
                img.Dispose();
            }
            catch (Exception)
            {

            }
        }
Пример #5
0
 private static void StoreDB(CaoQunMainItem caoQunMainItem)
 {
     DapperHelper dh = DapperHelper.GetInstance("Data Source=.;Initial Catalog=DeanDB;Integrated Security=True");
     const string sqlFormat =
     @"INSERT INTO [dbo].[WebCrawlerResult]
        ([Title]
        ,[PicDic]
        ,[Url]
        ,[Remark])
      VALUES
        ('{0}'
        ,'{1}'
        ,'{2}'
        ,'{3}')";
     string sql = string.Format(sqlFormat, caoQunMainItem.Title, caoQunMainItem.CaoQunDetailItem.PicDic,
         caoQunMainItem.InfoUrl, caoQunMainItem.Remark);
     dh.Execute(sql);
 }
Пример #6
0
        private List<CaoQunMainItem> GetCaoQunMainItems()
        {
            List<CaoQunMainItem> res = new List<CaoQunMainItem>();
            HttpCore hc = new HttpCore();
            hc.SetUrl(CaoQunUrl);
            string mainHtml = hc.GetHtml();
            HtmlNodeCollection mainItems = mainHtml.SelectNodes("//*[@id='ajaxtable']/tbody[1]/tr[@class='tr3 t_one']");
            if (mainItems == null)
            {
                return new List<CaoQunMainItem>();
            }
            foreach (HtmlNode mainItem in mainItems)
            {
                var an = mainItem.SelectSingleNode("/td[2]/h3/a");

                string infoUrl = "http://ac168.info/bt/" + an.Attributes["href"].Value;
                string title = an.InnerText;

                CaoQunMainItem temp = new CaoQunMainItem
                {
                    CaoQunDetailItem = new CaoQunDetailItem(),
                    InfoUrl = infoUrl,
                    Title = title,
                    Url = CaoQunUrl
                };
                res.Add(temp);
            }
            return res;
        }