Beispiel #1
0
        private void btn_test_Click(object sender, EventArgs e)
        {
            // #todo 输入检查,数字1~10only
            int culture; //4 china1,Egypt2, Babylon3, India4
            int wealth;  //1~10
            int density; //1~10
            int tech;    //1~10

            if (rbtn_Babylon.Checked == true)
            {
                culture = 3;
            }
            else if (rbtn_China.Checked == true)
            {
                culture = 1;
            }
            else if (rbtn_Egypt.Checked == true)
            {
                culture = 2;
            }
            else
            {
                culture = 4;
            }
            wealth = Convert.ToInt16(tbx_Wealth.Text);
            density = Convert.ToInt16(tbx_Density.Text);
            tech = Convert.ToInt16(tbx_Tech.Text);

            House house1 = new House(culture, wealth, density, tech);
            house1.input_processing();

            Graphics g = this.CreateGraphics();  //创建grahics对象实例
            //定义矩形区域
            Rectangle rect = new Rectangle(50, 350-house1.Wall_height , house1.Wall_weight, house1.Wall_height);
            //定义画刷对象
            LinearGradientBrush lBrush = new LinearGradientBrush(rect, house1.Color, house1.Color, LinearGradientMode.BackwardDiagonal);
            //填充矩形
            g.FillRectangle(lBrush, rect);
        }
Beispiel #2
0
        void Browser_DocumentCompleted(object sender, EventArgs e)
        {
            GeckoWebBrowser br = sender as GeckoWebBrowser;
            //加载成功开始分析。
            if (br.Url.ToString() == "about:blank") { return; }
            ShowClickMsg("加载成功开始分析" + br.Url.ToString());
            Log.logger("加载成功开始分析" + br.Url.ToString());

            int CountLoupan = 0;
            foreach (Skybound.Gecko.GeckoElement a in br.Document.Links)
            {
                if (a.Parent != null &&
               a.Parent.Parent != null &&
                   a.Parent.Parent.ClassName != null &&
               a.Parent.Parent.ClassName == "t"
               &&
               a.Parent.Parent.Parent != null &&
                     a.Parent.Parent.Parent.ClassName != null &&
                           a.Parent.Parent.Parent.ClassName == "h3 clear" &&
                  a.Parent.Parent.Parent.Parent != null &&
                    a.Parent.Parent.Parent.Parent.ClassName != null &&
               a.Parent.Parent.Parent.Parent.ClassName == "rinfo"
               )
                {
                    CountLoupan++;
                    if (a.TextContent == null) { continue; }

                    House hous = new House();
                    string price = a.Parent.Parent.Parent.ChildNodes[3].TextContent.Replace("\n\n\t\t\t    \n\t\t\t    ","");
                    //		price.Replace("元/平米", "").Replace("均价:", "").Replace(",", "").Trim()	"起价:75万元/套"	string
                    if (price == "        ")
                    {
                        hous.Price = 0;
                    }
                    else
                    {
                        //最高价:8,016万元/套
                        int priceint = 0;
                        string trimprice = price.Replace(",", "");
                        if (price.IndexOf("元/平米") >= 0)
                        {
                            trimprice = price.Replace("元/平米", "").Replace("均价:", "").Replace(",", "").Replace("起价:", "").Replace("二手房参考价:", "");
                            int.TryParse(trimprice, out priceint);
                            hous.Price = priceint;
                            hous.Danwei = "元/平米";
                        }
                        if (price.IndexOf("万元/套") >= 0)
                        {
                            trimprice = price.Replace("万元/套", "").Replace("最高价:", "").Replace(",", "").Replace("起价:", "");
                            int.TryParse(trimprice, out priceint);
                            hous.Price = priceint;
                            hous.Danwei = "万元/套";
                        }
                    }

                    hous.Name = a.Parent.Parent.Parent.ChildNodes[1].ChildNodes[0].TextContent;

                    Skybound.Gecko.GeckoElement isnew = (Skybound.Gecko.GeckoElement)a.Parent.Parent.ChildNodes[1];

                    hous.HouseType = isnew.TextContent;

                    string[] sArray = Regex.Split(GetUrl(), "housemarket", RegexOptions.IgnoreCase);

                    // 均价:12,800元/平米
                    hous.urll =sArray[0]+ a.GetAttribute("href").TrimStart('/');

                    Skybound.Gecko.GeckoElement divadd = (Skybound.Gecko.GeckoElement)a.Parent.Parent.Parent.Parent;
                    Skybound.Gecko.GeckoElement wuye = (Skybound.Gecko.GeckoElement)divadd.ChildNodes[3];
                    string wuyename = wuye.ChildNodes[1].TextContent;//物业类型:普通住宅 别墅 花园洋房

                    string phone = wuye.ChildNodes[3].TextContent.Replace("\n\t\t\t\t", "");//电话:400-888-2200 转 13923

                    Skybound.Gecko.GeckoNode kaifangshang = (Skybound.Gecko.GeckoNode)divadd.ChildNodes[5];
                    string address = kaifangshang.TextContent;
                    if (wuyename != null)
                    {
                        hous.wuyeleixing = wuyename.Replace("物业类型:", "");
                    }
                    else
                    {
                        hous.wuyeleixing = "无";
                    }
                    if (phone != null)
                    {
                        hous.phones = phone.Replace("电话:", "");
                    }
                    else
                    {
                        hous.phones = "无";
                    }
                    string[] kaifang_address = address.Split(new string[] { "查看地图" }, StringSplitOptions.RemoveEmptyEntries);
                    if (kaifang_address.Length >= 2)
                    {
                        hous.Kaifangshang = kaifang_address[1].Replace("开 发 商:", "");
                        hous.address = kaifang_address[0].Replace("物业地址:", "");
                    }
                    else
                    {
                        hous.Kaifangshang = address;//物业地址:大兴京开高速庞各庄出口南1000米查看地图\r\n开 发 商:北京富源盛达房地产开发有限公司
                        hous.address = "无法识别地址";
                    }
                    if (hous.Danwei == null)
                    {
                        hous.Danwei = "";
                    }
                    if (hous.wuyeleixing == null)
                    {
                        hous.wuyeleixing = "";
                    }
                    if (hous.phones == null)
                    {
                        hous.phones = "";
                    }
                    if (hous.Kaifangshang == null)
                    {
                        hous.Kaifangshang = "";
                    }

                    ShowClickMsg(i + "_" + "楼盘:" + hous.Name.Trim() + ";" + hous.Price + " " + hous.Danwei.Trim() + ";" + hous.wuyeleixing.Trim() + ";" + hous.phones.Trim() + ";" + hous.Kaifangshang.Trim());
                    House house = CItyhouseList.SingleOrDefault(item => item.urll == hous.urll);
                    if (house == null)
                    {
                        hous.ID = AllCItyCount;
                        ShowLoadddingMsg(AllCItyCount.ToString());
                        CItyhouseList.Add(hous);
                        AllCItyCount++;
                    }
                }
            }
            i++;
            count++;
            string urll = GetUrl() + "index.php?page=" + i;// "http://sh.focus.cn/housemarket/house_search/index.php?page=" + i;
            ShowClickMsg(urll);
            string page = GetPage();
            if (page == "")
            {
                page = "300";
            }

            System.GC.Collect();
            if (i < int.Parse(page) && CountLoupan > 0)
            {
                this.Browser.Navigate(urll);
            }
            else // if (CountLoupan == 0) //没有查找到新页面了。就可以查找二级页面了。
            {
                this.Browser.DocumentCompleted -= new  EventHandler(Browser_DocumentCompleted);
                this.Browser.DocumentCompleted += new EventHandler(Browser_DocumentCompleted_xiangxi);
                GetOneUrlandnagative();

            }
        }
Beispiel #3
0
        protected virtual void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            //加载成功开始分析。
            if (e.Url.ToString() == "about:blank")
            {
                return;
            }
            ShowClickMsg("加载成功开始分析" + e.Url.ToString());
            Log.logger("加载成功开始分析" + e.Url.ToString());

            IHTMLDocument2 doc         = (IHTMLDocument2)webBrowser.Document.DomDocument;
            int            CountLoupan = 0;

            foreach (mshtml.IHTMLElement a in doc.links)
            {
                if (a.parentElement != null &&
                    a.parentElement.parentElement != null &&
                    a.parentElement.parentElement.className != null &&
                    a.parentElement.parentElement.className == "t"
                    &&
                    a.parentElement.parentElement.parentElement != null &&
                    a.parentElement.parentElement.parentElement.className != null &&
                    a.parentElement.parentElement.parentElement.className == "h3 clear" &&
                    a.parentElement.parentElement.parentElement.parentElement != null &&
                    a.parentElement.parentElement.parentElement.parentElement.className != null &&
                    a.parentElement.parentElement.parentElement.parentElement.className == "rinfo"
                    )
                {
                    CountLoupan++;
                    if (a.innerText == null)
                    {
                        continue;
                    }

                    House  hous  = new House();
                    string price = a.parentElement.parentElement.parentElement.children[1].innerText;
                    //		price.Replace("元/平米", "").Replace("均价:", "").Replace(",", "").Trim()	"起价:75万元/套"	string
                    if (price == "        ")
                    {
                        hous.Price = 0;
                    }
                    else
                    {
                        //最高价:8,016万元/套
                        int    priceint  = 0;
                        string trimprice = price.Replace(",", "");
                        if (price.IndexOf("元/平米") >= 0)
                        {
                            trimprice = price.Replace("元/平米", "").Replace("均价:", "").Replace(",", "").Replace("起价:", "").Replace("二手房参考价:", "");
                            int.TryParse(trimprice, out priceint);
                            hous.Price  = priceint;
                            hous.Danwei = "元/平米";
                        }
                        if (price.IndexOf("万元/套") >= 0)
                        {
                            trimprice = price.Replace("万元/套", "").Replace("最高价:", "").Replace(",", "").Replace("起价:", "");
                            int.TryParse(trimprice, out priceint);
                            hous.Price  = priceint;
                            hous.Danwei = "万元/套";
                        }
                    }
                    hous.Name = a.innerText;

                    HTMLDivElement isnew = (HTMLDivElement)a.parentElement.parentElement.children[1];

                    hous.HouseType = isnew.innerText;
                    // 均价:12,800元/平米
                    hous.urll = a.getAttribute("href");

                    HTMLDivElement divadd   = (HTMLDivElement)a.parentElement.parentElement.parentElement.parentElement;
                    HTMLDivElement wuye     = (HTMLDivElement)divadd.children[1];
                    string         wuyename = wuye.children[0].innerText; //物业类型:普通住宅 别墅 花园洋房

                    string phone = wuye.children[1].innerText;            //电话:400-888-2200 转 13923

                    HTMLDivElement kaifangshang = (HTMLDivElement)divadd.children[2];
                    string         address      = kaifangshang.innerText;
                    if (wuyename != null)
                    {
                        hous.wuyeleixing = wuyename.Replace("物业类型:", "");
                    }
                    else
                    {
                        hous.wuyeleixing = "无";
                    }
                    if (phone != null)
                    {
                        hous.phones = phone.Replace("电话:", "");
                    }
                    else
                    {
                        hous.phones = "无";
                    }
                    string[] kaifang_address = address.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                    if (kaifang_address.Length >= 2)
                    {
                        hous.Kaifangshang = kaifang_address[1].Replace("开 发 商:", "");
                        hous.address      = kaifang_address[0].Replace("物业地址:", "");
                    }
                    else
                    {
                        hous.Kaifangshang = address;    //物业地址:大兴京开高速庞各庄出口南1000米查看地图\r\n开 发 商:北京富源盛达房地产开发有限公司
                        hous.address      = "无法识别地址";
                    }
                    ShowClickMsg(i + "_" + "楼盘:" + hous.Name + ";" + hous.Price + " " + hous.Danwei + ";" + hous.wuyeleixing + ";" + hous.phones + ";" + hous.Kaifangshang);
                    House house = CItyhouseList.SingleOrDefault(item => item.urll == hous.urll);
                    if (house == null)
                    {
                        hous.ID = AllCItyCount;
                        CItyhouseList.Add(hous);
                        AllCItyCount++;
                    }
                }
            }
            i++;
            count++;
            string urll = GetUrl() + "index.php?page=" + i;    // "http://sh.focus.cn/housemarket/house_search/index.php?page=" + i;

            ShowClickMsg(urll);
            string page = GetPage();

            if (page == "")
            {
                page = "300";
            }
            IEUtil.CleanCookie();
            IEUtil.CleanTempFiles();
            System.GC.Collect();
            if (i < int.Parse(page) && CountLoupan > 0)
            {
                this.webBrowser.Navigate(urll);
            }
            else if (CountLoupan == 0)       //没有查找到新页面了。就可以查找二级页面了。
            {
                this.webBrowser.DocumentCompleted -= new WebBrowserDocumentCompletedEventHandler(webBrowser_DocumentCompleted);
                this.webBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser_DocumentCompleted3);
                GetOneUrlandnagative();
            }
        }
Beispiel #4
0
        protected virtual void webBrowser_DocumentCompleted3(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            //加载成功开始分析。
            if (e.Url.AbsolutePath != (sender as WebBrowser).Url.AbsolutePath)
            {
                return;
            }
            if (webBrowser.ReadyState != WebBrowserReadyState.Complete)
            {
                return;
            }
            if (e.Url.ToString() == "about:blank")
            {
                return;
            }
            IEUtil.CleanCookie();
            IEUtil.CleanTempFiles();
            System.GC.Collect();
            try
            {
                ShowClickMsg("开始加载每个楼盘的数据 " + (sender as WebBrowser).Url.AbsolutePath);
                IHTMLDocument2 doc = (IHTMLDocument2)webBrowser.Document.DomDocument;
                foreach (mshtml.IHTMLElement a in doc.links)
                {
                    if (
                        a.parentElement != null &&
                        a.parentElement.tagName != null &&
                        a.parentElement.tagName.ToLower() == "li" &&
                        a.parentElement.parentElement != null &&
                        a.parentElement.parentElement.tagName != null &&
                        a.parentElement.parentElement.tagName.ToLower() == "ul" &&
                        a.parentElement.parentElement.parentElement != null &&
                        a.parentElement.parentElement.parentElement.className != null &&
                        a.parentElement.parentElement.parentElement.className == "blockLA" &&
                        a.parentElement.parentElement.parentElement.parentElement != null &&
                        a.parentElement.parentElement.parentElement.parentElement.className != null &&
                        a.parentElement.parentElement.parentElement.parentElement.className == "l"
                        &&
                        a.parentElement.parentElement.parentElement.parentElement.parentElement != null &&
                        a.parentElement.parentElement.parentElement.parentElement.parentElement.className != null &&
                        a.parentElement.parentElement.parentElement.parentElement.parentElement.className == "area"
                        &&
                        a.parentElement.parentElement.parentElement.parentElement.parentElement.id == "contentB"
                        )
                    {
                        House house = CItyhouseList.Where(item => item.urll == (sender as WebBrowser).Url.AbsoluteUri.ToString()).ToList()[0];
                        if (house != null)
                        {
                            house.IsSearch = true;
                        }
                        else
                        {
                            GetOneUrlandnagative(); return;
                        }
                        if (house != null)
                        {
                            HTMLDivElement divinfoo = (HTMLDivElement)a.parentElement.parentElement.parentElement.parentElement.parentElement;

                            HTMLDivElement   divclass111 = (HTMLDivElement)divinfoo.children[0];
                            HTMLDivElement   divblockaaa = (HTMLDivElement)divclass111.children[0];
                            HTMLUListElement ulll1       = (HTMLUListElement)divblockaaa.children[0];
                            house.updateTime = ((HTMLLIElement)ulll1.children[0]).children[1].innerText;
                            house.AlongArea  = ((HTMLLIElement)ulll1.children[2]).innerText.Replace("所属片区:", "");

                            HTMLDivElement   divblockBBBB = (HTMLDivElement)divclass111.children[1];
                            HTMLUListElement ulllBBBB     = (HTMLUListElement)divblockBBBB.children[0];
                            house.Jiaotong   = ((HTMLLIElement)ulllBBBB.children[0]).innerText.Replace("周围交通:", "");
                            house.opentime   = ((HTMLLIElement)ulllBBBB.children[1]).innerText.Replace("开盘时间:", "");
                            house.LiveIntime = ((HTMLLIElement)ulllBBBB.children[2]).innerText.Replace("入住时间:", "");
                        }
                        string name = ListCItyUrl.SingleOrDefault(item => item.Value == GetUrl()).Key;
                        Log.Datalogger(house.ID + "," + house.Name.Replace(",", "、") + "," + house.HouseType.Replace(",", "、") + "," + house.Price + "," + house.Danwei + "," + house.phones.Replace(",", "、") + "," + house.AlongArea.Replace(",", "、") + "," +
                                       house.address.Replace(",", "、").Replace("查看地图", "") + "," + house.Kaifangshang.Replace(",", "、") + "," + house.Jiaotong.Replace(",", "、") + "," +
                                       house.opentime.Replace(",", "、") + "," + house.LiveIntime.Replace(",", "、") + "," + house.updateTime.Replace(",", "、") + "," + house.wuyeleixing.Replace(",", "、"), name);
                        break;
                    }
                }
                GetOneUrlandnagative();
            }
            catch (Exception ex)
            {
                Log.logger(ex.Message + ex.StackTrace);
                GetOneUrlandnagative();
            }
        }
Beispiel #5
0
        protected virtual void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            //加载成功开始分析。
            if (e.Url.ToString() == "about:blank") { return; }
            ShowClickMsg("加载成功开始分析" + e.Url.ToString());
            Log.logger("加载成功开始分析" + e.Url.ToString());

            IHTMLDocument2 doc = (IHTMLDocument2)webBrowser.Document.DomDocument;
            int CountLoupan = 0;
                foreach (mshtml.IHTMLElement a in doc.links)
                {
                    if (a.parentElement != null &&
                   a.parentElement.parentElement != null &&
                       a.parentElement.parentElement.className != null &&
                   a.parentElement.parentElement.className== "t"
                   &&
                   a.parentElement.parentElement.parentElement != null &&
                         a.parentElement.parentElement.parentElement.className != null &&
                               a.parentElement.parentElement.parentElement.className == "h3 clear" &&
                      a.parentElement.parentElement.parentElement.parentElement != null &&
                        a.parentElement.parentElement.parentElement.parentElement.className != null &&
                   a.parentElement.parentElement.parentElement.parentElement.className == "rinfo"
                   )
                    {
                        CountLoupan++;
                        if (a.innerText == null) { continue; }

                        House hous = new House();
                        string price = a.parentElement.parentElement.parentElement.children[1].innerText;
                        //		price.Replace("元/平米", "").Replace("均价:", "").Replace(",", "").Trim()	"起价:75万元/套"	string
                        if (price == "        ")
                        {
                            hous.Price = 0;
                        }
                        else
                        {
                            //最高价:8,016万元/套
                            int priceint = 0;
                            string trimprice = price.Replace(",", "");
                            if (price.IndexOf("元/平米")>=0){
                                trimprice = price.Replace("元/平米", "").Replace("均价:", "").Replace(",", "").Replace("起价:", "").Replace("二手房参考价:", "");
                                int.TryParse(trimprice, out priceint);
                                hous.Price = priceint;
                                hous.Danwei = "元/平米";
                            }
                            if (price.IndexOf("万元/套") >= 0)
                            {
                                trimprice = price.Replace("万元/套", "").Replace("最高价:", "").Replace(",", "").Replace("起价:", "");
                                int.TryParse(trimprice, out priceint);
                                hous.Price = priceint;
                                hous.Danwei = "万元/套";
                            }
                        }
                        hous.Name=a.innerText;

                        HTMLDivElement isnew = (HTMLDivElement) a.parentElement.parentElement.children[1];

                        hous.HouseType = isnew.innerText;
                        // 均价:12,800元/平米
                        hous.urll = a.getAttribute("href");

                        HTMLDivElement divadd=(HTMLDivElement)a.parentElement.parentElement.parentElement.parentElement;
                        HTMLDivElement wuye = (HTMLDivElement)divadd.children[1];
                        string wuyename = wuye.children[0].innerText;//物业类型:普通住宅 别墅 花园洋房

                        string phone = wuye.children[1].innerText;//电话:400-888-2200 转 13923

                        HTMLDivElement kaifangshang = (HTMLDivElement)divadd.children[2];
                        string address = kaifangshang.innerText;
                        if (wuyename != null)
                        {
                            hous.wuyeleixing = wuyename.Replace("物业类型:", "");
                        }
                        else
                        {
                            hous.wuyeleixing = "无";
                        }
                        if (phone != null)
                        {
                            hous.phones = phone.Replace("电话:", "");
                        }
                        else
                        {
                            hous.phones = "无";
                        }
                        string[] kaifang_address = address.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                        if (kaifang_address.Length >= 2)
                        {
                            hous.Kaifangshang = kaifang_address[1].Replace("开 发 商:", "");
                            hous.address = kaifang_address[0].Replace("物业地址:", "");
                        }
                        else
                        {
                            hous.Kaifangshang = address;//物业地址:大兴京开高速庞各庄出口南1000米查看地图\r\n开 发 商:北京富源盛达房地产开发有限公司
                            hous.address = "无法识别地址";
                        }
                        ShowClickMsg(i+"_"+"楼盘:" + hous.Name +";"+ hous.Price+" "+hous.Danwei +";"+hous.wuyeleixing+";"+hous.phones+";"+hous.Kaifangshang);
                        House house = CItyhouseList.SingleOrDefault(item => item.urll == hous.urll);
                        if (house == null)
                        {
                            hous.ID = AllCItyCount;
                            CItyhouseList.Add(hous);
                            AllCItyCount++;
                        }

                    }
                }
                i++;
                count++;
                string urll = GetUrl() + "index.php?page=" + i;// "http://sh.focus.cn/housemarket/house_search/index.php?page=" + i;
                ShowClickMsg(urll);
                string page = GetPage();
                if (page == "")
                {
                    page = "300";
                }
                IEUtil.CleanCookie();
                IEUtil.CleanTempFiles();
                System.GC.Collect();
                if (i < int.Parse(page) && CountLoupan > 0)
                {
                    this.webBrowser.Navigate(urll);
                }
                else   if (CountLoupan == 0) //没有查找到新页面了。就可以查找二级页面了。
                {
                    this.webBrowser.DocumentCompleted -= new WebBrowserDocumentCompletedEventHandler(webBrowser_DocumentCompleted);
                    this.webBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser_DocumentCompleted3);
                    GetOneUrlandnagative();

                }
        }