示例#1
0
        private static void StoreDB(MainItem 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.HPLDetailItem.PicDic,
                                       caoQunMainItem.InfoUrl, caoQunMainItem.Remark);

            dh.Execute(sql);
        }
示例#2
0
        private static void SaveImg(string imgFileName, MainItem caoQunMainItem, Image img, string imgUrl)
        {
            try
            {
                caoQunMainItem.HPLDetailItem.PicUrl = imgUrl;
                Console.WriteLine(imgUrl);

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

                img.Save(pic.Trim('?'));
                img.Dispose();
            }
            catch (Exception)
            {
            }
        }
示例#3
0
        private static void SaveImg(string imgFileName, MainItem caoQunMainItem, Image img, string imgUrl)
        {
            try
            {
                caoQunMainItem.HPLDetailItem.PicUrl = imgUrl;
                Console.WriteLine(imgUrl);

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

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

            }
        }
示例#4
0
 private static void StoreDB(MainItem 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,
         string.Empty,
         caoQunMainItem.InfoUrl,
         caoQunMainItem.Remark);
     dh.Execute(sql);
 }
示例#5
0
        private List <MainItem> GetCaoQunMainItems()
        {
            List <MainItem> res = new List <MainItem>();
            HttpCore        hc  = new HttpCore();

            hc.SetUrl(CaoQunUrl);
            string mainHtml = hc.GetHtml();

            //MSScriptControl.ScriptControlClass scc = new MSScriptControl.ScriptControlClass { Language = "javascript" };
            //mainHtml = scc.Eval(mainHtml).ToString();

            ThreadWebBrowser(CaoQunUrl);
            while (kM == null)
            {
                Thread.Sleep(1000);
            }
            HtmlNodeCollection mainItems = mainHtml.SelectNodes("/html/body/div[8]/div[2]/div[@class='list-pianyuan-box']");

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

                string infoUrl = "http://www.haipilu.net/" + an.Attributes["href"].Value;
                string title   = an.InnerText;

                MainItem temp = new MainItem
                {
                    HPLDetailItem = new HPLDetailItem(),
                    InfoUrl       = infoUrl,
                    Title         = title,
                    Url           = CaoQunUrl
                };
                res.Add(temp);
            }
            return(res);
        }
示例#6
0
        private IEnumerable <MainItem> GetCaoQunMainItems()
        {
            List <MainItem> res = new List <MainItem>();
            HttpCore        hc  = new HttpCore();

            hc.SetUrl(CaoQunUrl);
            hc.CurrentHttpItem.Allowautoredirect = true;
            string mainHtml = hc.GetHtml();

            HtmlNodeCollection mainItems = mainHtml.SelectNodes("//*[@id='ajaxtable']/tbody[1]/tr");

            if (mainItems == null)
            {
                return(new List <MainItem>());
            }
            foreach (HtmlNode mainItem in mainItems)
            {
                var an = mainItem.SelectSingleNode(mainItem.XPath + "/td[2]/h3/a");
                if (an == null)
                {
                    continue;
                }
                string infoUrl = "http://5.yao.cl/" + an.Attributes["href"].Value;
                string title   = an.InnerText;

                MainItem temp = new MainItem
                {
                    HPLDetailItem = new HPLDetailItem(),
                    InfoUrl       = infoUrl,
                    Title         = title,
                    Url           = CaoQunUrl
                };
                res.Add(temp);
            }
            return(res);
        }
示例#7
0
        private List<MainItem> GetCaoQunMainItems()
        {
            List<MainItem> res = new List<MainItem>();
            HttpCore hc = new HttpCore();
            hc.SetUrl(CaoQunUrl);
            string mainHtml = hc.GetHtml();

            //MSScriptControl.ScriptControlClass scc = new MSScriptControl.ScriptControlClass { Language = "javascript" };
            //mainHtml = scc.Eval(mainHtml).ToString();

            ThreadWebBrowser(CaoQunUrl);
            while (kM == null)
            {
                Thread.Sleep(1000);
            }
            HtmlNodeCollection mainItems = mainHtml.SelectNodes("/html/body/div[8]/div[2]/div[@class='list-pianyuan-box']");
            if (mainItems == null)
            {
                return new List<MainItem>();
            }
            foreach (HtmlNode mainItem in mainItems)
            {
                var an = mainItem.SelectSingleNode("/div[1]/div[2]/div[1]/a");

                string infoUrl = "http://www.haipilu.net/" + an.Attributes["href"].Value;
                string title = an.InnerText;

                MainItem temp = new MainItem
                {
                    HPLDetailItem = new HPLDetailItem(),
                    InfoUrl = infoUrl,
                    Title = title,
                    Url = CaoQunUrl
                };
                res.Add(temp);
            }
            return res;
        }
示例#8
0
        private IEnumerable<MainItem> GetCaoQunMainItems()
        {
            List<MainItem> res = new List<MainItem>();
            HttpCore hc = new HttpCore();
            hc.SetUrl(CaoQunUrl);
            hc.CurrentHttpItem.Allowautoredirect = true;
            string mainHtml = hc.GetHtml();

            HtmlNodeCollection mainItems = mainHtml.SelectNodes("//*[@id='ajaxtable']/tbody[1]/tr");
            if (mainItems == null)
            {
                return new List<MainItem>();
            }
            foreach (HtmlNode mainItem in mainItems)
            {
                var an = mainItem.SelectSingleNode(mainItem.XPath + "/td[2]/h3/a");
                if (an == null)
                {
                    continue;
                }
                string infoUrl = "http://5.yao.cl/" + an.Attributes["href"].Value;
                string title = an.InnerText;

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