Пример #1
0
        void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (e.Url != Document.Url) return;
            if (e.Url.ToString().StartsWith("http://www.xzhouse.com.cn/houseSearch.aspx?page="))
            {
                if (pageMax < 0)
                {
                    try
                    {
                        Regex reg = new Regex("共(\\d+)页");
                        Match m = reg.Match(Document.Body.InnerText);
                        pageMax = int.Parse(m.Groups[1].Value);
                    }
                    catch { pageMax = 100; }
                }
                foreach (HtmlElement link in Document.GetElementsByTagName("a"))
                {
                    try
                    {
                        string strLink = link.GetAttribute("href");
                        if (strLink.StartsWith("http://www.xzhouse.com.cn/ItemSellInfo.aspx?ID=") && !Fn.IsExistEstUrl(strLink) && !UrlInLinkList(strLink)) listLink.Add(new KeyValuePair<string, object>(strLink, link.InnerText));
                    }
                    catch { }
                }

                this.NavToNextPage();
                return;
            }

            try
            {
                Model_Estate me = new Model_Estate("徐州");
                me.SourceLink = linkCurrent.Key;
                me.EstNum = me.SourceLink.Split('=')[1].Split('&')[0];
                me.EstName = Document.GetElementById("lblItemName").InnerText;
                me.DistrictName = Document.GetElementById("lblDist").InnerText;
                me.EstAddr = Document.GetElementById("lblItemSite").InnerText;
                me.PlateName = Document.GetElementById("lblZone").InnerText;
                me.Developer = Document.GetElementById("lblCorpName").InnerText;
                me.EstUsage = Document.GetElementById("lblPlUse").InnerText;
                me.ProjectApprovals = Document.GetElementById("lblItAcPaper").InnerText;
                me.ProjectPermitNum = Document.GetElementById("lblItPlLicNum").InnerText;
                me.LandPermitNum = Document.GetElementById("lblItLaUseLic").InnerText;
                me.ConstructionPermitNum = Document.GetElementById("lblIStruLicNum").InnerText;
                me.GroundAreaAll = double.Parse(Document.GetElementById("lblLaAcre").InnerText);
                me.GroundPermitNum = Document.GetElementById("lblLaCertNum").InnerText;
                me.CompletionTime = Document.GetElementById("lblWoFinDate").InnerText;
                me.CountAll = int.Parse(Document.GetElementById("lblSumSuits").InnerText);
                me.BuildingAreaAll = double.Parse(Document.GetElementById("lblSumArea").InnerText);
                me.AreaSold = double.Parse(Document.GetElementById("lblSelledArea").InnerText);
                me.Save();
            }
            catch { }

            this.NavToNext();
        }
Пример #2
0
        void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (e.Url.ToString() != Document.Url.ToString()) return;
            if (e.Url.ToString().StartsWith("http://www.lousw.com/loupanfnewsearch.asp?pages0="))
            {
                HtmlElement tbody = Document.Body.Children[6].Children[1];
                if (tbody.Children[2].Children.Count == 1)
                {
                    this.NavToNext();
                    return;
                }
                for (int i = 2; i < tbody.Children.Count-1; i++)
                {
                    HtmlElement tr = tbody.Children[i];
                    string strLink = tr.Children[1].Children[0].GetAttribute("href");
                    if (!Fn.IsExistEstUrl(strLink) && !UrlInLinkList(strLink)) listLink.Add(new KeyValuePair<string, object>(strLink, tr.Children[0].InnerText));
                }

                this.NavToNextPage(); return;
            }

            try
            {
                Model_Estate me = new Model_Estate("淮安");
                me.SourceLink = linkCurrent.Key;
                me.EstNum = me.SourceLink.Split('=')[1];
                me.DistrictName = linkCurrent.Value.ToString();
                HtmlElement body = Document.Body;
                HtmlElement info = body.Children[14].GetElementsByTagName("table")[2].Children[0].Children[0].Children[0];
                string strTmp = info.InnerText;
                me.EstName = strTmp.Substring(0, strTmp.IndexOf("(")).Trim();
                me.Developer = strTmp.Substring(strTmp.IndexOf(":")+1).Trim(')').Trim();

                info = body.Children[16].Children[0].Children[0].Children[2].Children[0].Children[0];

                HtmlElement info1 = info.Children[3].GetElementsByTagName("tbody")[1];
                me.SaleTele = info1.Children[1].InnerText;
                me.SaleAddr = info1.Children[2].InnerText.Split(':')[1];
                me.EstAddr = info1.Children[3].InnerText.Split(':')[1];

                info1 = info.Children[7].Children[0].Children[0].Children[0].Children[1].Children[0];
                me.CountAll = int.Parse(info1.InnerText.Replace("套", ""));

                info1 = info.Children[17].Children[0].Children[0].Children[0];
                me.Traffic = info1.Children[1].Children[0].InnerText;
                me.SrdFacility = info1.Children[3].Children[0].InnerText;
                me.Save();
            }
            catch { }
            this.NavToNext();
        }
Пример #3
0
        void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (e.Url.ToString() != Document.Url.ToString()) return;
            if (e.Url.ToString().StartsWith("http://www.lygfdc.com/WebSite/Search/Default.aspx"))
            {
                HtmlElementCollection coll = Document.GetElementById("ctl00_CPH_M_sm_sBox_data").Children[0].GetElementsByTagName("dl");
                if (coll.Count == 0) { this.NavToNext(); return; }
                foreach (HtmlElement dl in coll)
                {
                    HtmlElement link = dl.Children[0].Children[0];
                    string strLink = link.GetAttribute("href");
                    if (!Fn.IsExistEstUrl(strLink) && !UrlInLinkList(strLink)) listLink.Add(new KeyValuePair<string, object>(strLink, link.InnerText));
                }
                this.NavToNextPage();
                return;
            }

            try
            {
                Model_Estate me = new Model_Estate("连云港");
                me.SourceLink = linkCurrent.Key;
                me.EstName = linkCurrent.Value.ToString();
                me.EstNum = me.SourceLink.Split('=')[1];

                HtmlElement info1 = Document.GetElementById("ctl00_CPH_M_sm_spfBox3").Children[0].Children[1].Children[0];
                me.DistrictName = info1.Children[0].Children[3].InnerText;
                me.EstAddr = info1.Children[1].Children[1].InnerText;
                me.CompletionTime = info1.Children[2].Children[3].InnerText;
                me.EstUsage = info1.Children[3].Children[1].InnerText;
                me.CountAll = int.Parse(info1.Children[5].Children[3].InnerText);
                me.Designer = info1.Children[6].Children[1].InnerText;
                me.Builder = info1.Children[6].Children[3].InnerText;
                me.PropertyCompany = info1.Children[8].Children[1].InnerText;
                me.PropertyFee = info1.Children[8].Children[3].InnerText;
                me.BuildingAreaAll = double.Parse(info1.Children[9].Children[1].InnerText);
                me.BuildingDensity = info1.Children[9].Children[3].InnerText;
                me.GroundAreaAll = double.Parse(info1.Children[11].Children[1].InnerText);
                me.GreeningRate = info1.Children[11].Children[3].InnerText;
                me.PlotRatio = info1.Children[12].Children[3].InnerText;

                info1 = Document.GetElementById("ctl00_CPH_M_sm_spfBox_dev").Children[0].Children[1].Children[0];
                me.Developer = info1.Children[0].Children[1].InnerText;

                info1 = Document.GetElementById("ctl00_CPH_M_sm_spfBox5").Children[0].Children[1];
                me.EstIntroduction = info1.InnerText;

                me.Save();
            }
            catch { }
            this.NavToNext();
        }
Пример #4
0
        void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (e.Url != Document.Url) return;
            if (e.Url.ToString().StartsWith("http://www.jy510.com/sinfo-page-"))
            {
                HtmlElement list = null;
                try
                {
                    list = Document.GetElementById("searchList").Children[0].Children[0];
                }
                catch { this.NavToNext(); return; }

                foreach (HtmlElement item in list.Children)
                {
                    try
                    {
                        HtmlElement link = item.Children[1].Children[0].Children[0];
                        string strLink = link.GetAttribute("href");
                        if (!this.UrlInLinkList(strLink))
                        {
                            if (!Fn.IsExistEstUrl(strLink)) listLink.Add(new KeyValuePair<string, object>(strLink, link.InnerText));
                        }
                        else
                        {
                            this.NavToNext(); return;
                        }
                    }
                    catch { }
                }

                this.NavToNextPage();
                return;
            }

            try
            {
                Model_Estate me = new Model_Estate("江阴");
                HtmlElement info1 = null;
                HtmlElement info2 = null;
                HtmlElement info3 = null;
                HtmlElement info4 = null;
                foreach (HtmlElement item in Document.GetElementsByTagName("div"))
                {
                    string cls = item.GetAttribute("classname");
                    if (cls == "house_information") info1 = item;
                    else if (cls == "generalize_con") info2 = item;
                    else if (cls == "nearby_table") info4 = item.Children[1].Children[1];
                    if (info1 != null && info2 != null && info4 != null) break;

                }

                foreach (HtmlElement item in Document.GetElementsByTagName("dl"))
                {
                    string cls = item.GetAttribute("classname");
                    if (cls == "generalize_table") { info3 = item; break; }
                }

                me.SourceLink = linkCurrent.Key;
                me.EstNum = me.SourceLink.Replace("http://www.jy510.com/sinfo-view-", "").Split('.')[0];
                me.EstName = linkCurrent.Value.ToString();

                if (info1 != null)
                {
                    me.EstAddr = info1.Children[0].Children[0].Children[1].InnerText;
                    me.DistrictName = info1.Children[0].Children[1].Children[1].InnerText;
                    me.PlateName = info1.Children[1].Children[1].Children[1].InnerText;
                    me.SaleAddr = info1.Children[2].Children[0].Children[1].InnerText;
                    me.DecorationLevel = info1.Children[2].Children[1].Children[1].InnerText;
                    me.EstUsage = info1.Children[3].Children[0].Children[1].InnerText;
                    me.SaleAgent = info1.Children[3].Children[1].Children[1].InnerText;
                    me.SaleTele = info1.Children[4].Children[0].Children[0].Children[1].InnerText;
                    me.Developer = info1.Children[5].Children[0].Children[1].InnerText.Replace("(查看)","").Trim();
                }

                if (info2 != null)
                {
                    me.EstIntroduction = info2.InnerText.Trim();
                }

                if (info3 != null)
                {
                    me.CountAll = int.Parse(info3.Children[1].InnerText.Replace("套", ""));
                    me.BuildingAreaAll = double.Parse(info3.Children[5].InnerText.Replace("万平方米", ""))*10000;
                    me.GroundAreaAll = double.Parse(info3.Children[7].InnerText.Replace("亩", "")) * 666.6666667;
                    me.PlotRatio = info3.Children[9].InnerText;
                    me.GreeningRate = info3.Children[11].InnerText;
                    me.PropertyCompany = info3.Children[13].InnerText;
                    me.PropertyFee = info3.Children[17].InnerText;
                }

                if (info4 != null)
                {
                    me.Traffic = info4.Children[1].InnerText;
                    me.SrdFacility = info4.Children[2].Children[1].InnerText;
                }

                me.Save();
            }
            catch { }

            this.NavToNext();
        }
Пример #5
0
        void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (e.Url != Document.Url) return;
            if (e.Url.ToString().StartsWith("http://beian.yxhouse.net/showConditionBuild.action"))
            {
                try
                {
                    if (Document.GetElementById("page").GetAttribute("value") != page.ToString()||page>2)
                    {
                        this.NavToNext(); return;
                    }
                }
                catch { this.NavToNext(); }

                HtmlElement div = null;
                foreach (HtmlElement el in Document.GetElementsByTagName("div"))
                {
                    if (el.GetAttribute("classname").ToLower() == "htba_center_left_1")
                    {
                        div = el; break;
                    }
                }
                if (div == null) { this.NavToNext(); return; }

                foreach (HtmlElement el in div.GetElementsByTagName("a"))
                {
                    try
                    {
                        string url = el.GetAttribute("href");
                        if (url.StartsWith("http://beian.yxhouse.net/buildDetail.action?blid="))
                        {
                            string prjid = url.Split('=')[1];
                            if (Fn.GetDT_PgSQL("select * from estate_info where cityid=" + cityId + " and estnum=" + q + prjid + q).Rows.Count > 0) continue;
                            listLink.Add(new KeyValuePair<string, object>(url, prjid));
                        }
                    }
                    catch { }
                }

                this.NavToNextPage();
                return;
            }

            try
            {
                Model_Estate me = new Model_Estate("宜兴");
                me.EstNum = linkCurrent.Value.ToString();
                me.SourceLink = linkCurrent.Key;
                foreach (HtmlElement div in Document.GetElementsByTagName("div"))
                {
                    try
                    {
                        if (div.GetAttribute("classname") != "sslp_lpxx_table_center") continue;
                        string name = div.Children[0].InnerText.Trim();
                        switch (name)
                        {
                            case "项目暂定名":
                                me.PublicName = div.Children[1].InnerText.Trim();
                                break;

                            case "项目现定名":
                                me.EstName = div.Children[1].InnerText.Trim();
                                break;

                            case "开发商":
                                me.Developer = div.Children[1].InnerText.Trim();
                                break;

                            case "坐落":
                                me.EstAddr = div.Children[1].InnerText.Trim();
                                break;

                            case "行政区":
                                me.DistrictName = div.Children[1].InnerText.Trim();
                                break;

                            case "区位":
                                me.PlateName = div.Children[1].InnerText.Trim();
                                break;

                            case "总建筑面积":
                                me.BuildingAreaAll = Convert.ToDouble(div.Children[1].InnerText.Trim().Replace("(单位:平方米)",""));
                                break;

                            case "立项批文":
                                me.ProjectApprovals = div.Children[1].InnerText.Trim();
                                break;

                            case "规划许可证号":
                                me.ProjectPermitNum = div.Children[1].InnerText.Trim();
                                break;

                            case "土地证号":
                                me.GroundPermitNum = div.Children[1].InnerText.Trim();
                                break;

                            case "施工许可证号":
                                me.ConstructionPermitNum = div.Children[1].InnerText.Trim();
                                break;

                            case "总用地":
                                me.GroundAreaAll = Convert.ToDouble(div.Children[1].InnerText.Trim().Replace("(单位:平方米)",""));
                                break;

                            case "当期用地":
                                me.GroundAreaCurrent = Convert.ToDouble(div.Children[1].InnerText.Trim().Replace("(单位:平方米)", ""));
                                break;

                            case "预计竣工日期":
                                me.CompletionTime = div.Children[1].InnerText.Trim();
                                break;

                            case "预售总面积":
                                me.BuildingAreaAll = Convert.ToDouble(div.Children[1].InnerText.Trim());
                                break;

                            case "总套数":
                                me.CountAll = Convert.ToInt32(div.Children[1].InnerText.Trim());
                                break;

                            case "代销公司":
                                me.SaleAgent = div.Children[1].InnerText.Trim();
                                break;

                            case "项目销售地点":
                                me.SaleAddr = div.Children[1].InnerText.Trim();
                                break;

                            case "电话":
                                me.SaleTele = div.Children[1].InnerText.Trim();
                                break;

                            case "物业公司":
                                me.PropertyCompany = div.Children[1].InnerText.Trim();
                                break;

                            case "物管费":
                                me.PropertyFee = div.Children[1].InnerText.Trim();
                                break;
                        }
                    }
                    catch { }

                }

                me.Save();
            }
            catch { }
            this.NavToNext();
        }
Пример #6
0
        void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (e.Url != Document.Url) return;
            if (e.Url.ToString().StartsWith("http://newhouse.suzhou.soufun.com/house/"))
            {
                HtmlElement list = GetElementByClassName("searchList", "div");
                if (list == null) { this.NavToNext(); return; }
                var flag = false;
                foreach (HtmlElement el in list.Children)
                {
                    if (el.GetAttribute("classname") != "searchListNoraml") continue;
                    try
                    {
                        string strLink = el.Children[1].Children[0].GetAttribute("href");
                        string strUsage = el.Children[2].Children[3].Children[0].Children[2].InnerText.Replace("[", "").Replace("]", "").Trim();
                        if (!Fn.IsExistEstUrl(strLink)) listLink.Add(new KeyValuePair<string, object>(strLink, strUsage));
                        flag = true;
                    }
                    catch { }
                }

                if (flag) this.NavToNextPage(); else this.NavToNext();
                return;
            }

            try
            {
                Model_Estate me = new Model_Estate("苏州");
                me.SourceLink = linkCurrent.Key;
                me.EstNum = Fn.GetMD5(linkCurrent.Key);
                me.EstName = Document.GetElementById("newsuzhouxq_B01_49").InnerText;
                me.EstUsage = linkCurrent.Value.ToString();
                me.EstAddr = "";

                HtmlElement intro = GetElementByClassName("zxseversubnav", "div");
                if (intro!=null && intro.NextSibling!=null && intro.NextSibling.NextSibling!=null)
                {
                    intro = intro.NextSibling.NextSibling;
                    intro = intro.Children[0];
                    if (intro!=null) me.EstIntroduction = intro.InnerText.Replace("简  介", "").Trim();
                }
                HtmlElement basicInfo = GetElementByClassName("basicinform", "div");
                if (basicInfo != null)
                {
                    try
                    {
                        basicInfo = basicInfo.Children[1].Children[0];

                        me.PropertyFee = basicInfo.Children[2].Children[0].Children[0].InnerText.Replace("物 业 费", "").Trim();
                        me.OpeningTime = basicInfo.Children[3].Children[0].InnerText.Replace("开盘时间","").Trim();
                        me.HandoverTime = basicInfo.Children[4].Children[0].InnerText.Replace("入住时间", "").Trim();
                        me.Developer = basicInfo.Children[5].Children[0].Children[0].InnerText.Replace("开 发 商", "").Trim();
                        me.SaleAddr = basicInfo.Children[6].Children[0].Children[0].InnerText.Replace("售楼地址","").Trim();

                    }
                    catch { }
                }

                HtmlElement detailInfo = Document.GetElementById("newsuzhouxq_B02_28");
                if (detailInfo != null)
                {
                    detailInfo = detailInfo.Children[0];
                    if (detailInfo != null)
                    {
                        me.GroundAreaAll = double.Parse(detailInfo.Children[1].Children[0].InnerText.Split(' ')[1].Replace("平方米", ""));
                        me.BuildingAreaAll = double.Parse(detailInfo.Children[1].Children[1].InnerText.Split(' ')[1].Replace("平方米", ""));
                        me.PlotRatio = detailInfo.Children[2].Children[0].InnerText.Replace("容 积 率","").Trim().Split(' ')[0];
                        me.GreeningRate = detailInfo.Children[2].Children[1].InnerText.Replace("绿 化 率", "").Trim().Split(' ')[0];
                        me.PropertyCompany = detailInfo.Children[4].Children[0].InnerText.Replace("物业管理公司", "").Trim();
                        me.Traffic = detailInfo.Children[5].InnerText.Replace("交通状况", "").Trim();
                    }
                }

                me.Save();
            }
            catch { }
            this.NavToNext();
        }
Пример #7
0
        void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (e.Url != Document.Url) return;
            if (e.Url.ToString() == "http://newhouse.njhouse.com.cn/kpgg/")
            {
                foreach (HtmlElement link in Document.GetElementsByTagName("a"))
                {
                    try
                    {
                        string strUrl = link.GetAttribute("href");
                        if (strUrl.StartsWith("http://newhouse.njhouse.com.cn/detail.php?id=") && !this.UrlInLinkList(strUrl) && !Fn.IsExistEstUrl(strUrl))
                        {
                            listLink.Add(new KeyValuePair<string, object>(strUrl, link.InnerText));
                        }
                    }
                    catch { }
                }
                this.NavToNext();
                return;
            }

            if (e.Url.ToString().StartsWith("http://newhouse.njhouse.com.cn/detail.php?id="))
            {
                try
                {
                    me = new Model_Estate("南京");

                    HtmlElement info1 = null;
                    HtmlElement info2 = null;
                    HtmlElement info3 = null;

                    foreach (HtmlElement td in Document.GetElementsByTagName("td"))
                    {
                        try
                        {
                            string tmp = td.InnerText.Replace(" ", "").Trim();
                            if (tmp == "项目地址:") info1 = td.Parent.Parent;
                            else if (tmp == "物业管理公司:") info2 = td.Parent.Parent;
                            else if (tmp == "周边环境:") info3 = td.Parent.Parent;
                        }
                        catch { }
                    }

                    me.SourceLink = linkCurrent.Key;
                    me.EstName = linkCurrent.Value.ToString();
                    me.EstAddr = info1.Children[0].Children[1].InnerText;
                    me.EstUsage = info1.Children[1].Children[1].InnerText;
                    me.DistrictName = info1.Children[2].Children[1].InnerText;

                    me.PropertyCompany = info2.Children[0].Children[1].InnerText;
                    me.Designer = info2.Children[1].Children[1].InnerText;
                    me.DecorationLevel = info2.Children[4].Children[1].InnerText;

                    me.SrdFacility = info3.Children[0].Children[1].InnerText;
                    me.EstFacility = info3.Children[1].Children[1].InnerText;
                    me.EstIntroduction = info3.Children[2].Children[1].InnerText;

                    HtmlElementCollection ifam = Document.GetElementsByTagName("iframe");
                    strUrl1 = ifam[2].GetAttribute("src");
                    strUrl2 = ifam[3].GetAttribute("src");
                    me.EstNum = strUrl1.Split('=')[1].Split('&')[0];
                }
                catch { me.Save(); this.NavToNext(); return; }

                this.Navigate(strUrl1);
            }
            else if (e.Url.ToString() == strUrl1)
            {
                try
                {
                    HtmlElement info = Document.Body.Children[0].Children[0];
                    me.Developer = info.Children[0].Children[1].InnerText;
                    me.SaleAgent = info.Children[1].Children[1].InnerText;
                    me.OpeningTime = info.Children[2].Children[3].InnerText;
                    //me.GroundPermitNum = info.Children[3].Children[1].InnerText;
                    //me.LandPermitNum = info.Children[3].Children[3].InnerText;
                    //me.ProjectPermitNum = info.Children[4].Children[1].InnerText;
                    //me.ConstructionPermitNum = info.Children[4].Children[3].InnerText;
                    this.Navigate(strUrl2);
                }
                catch { me.Save(); this.NavToNext(); return; }

            }
            else if (e.Url.ToString() == strUrl2)
            {
                try
                {
                    this.strUrl3 = "http://www.njhouse.com.cn/" + Document.GetElementsByTagName("iframe")[0].GetAttribute("src").Replace("../../", "");
                    this.Navigate(strUrl3);
                }
                catch { me.Save(); this.NavToNext(); return; }
            }
            else if (e.Url.ToString() == strUrl3)
            {
                try
                {
                    HtmlElement info = Document.Body.Children[0].Children[0];
                    me.CountAll = int.Parse(info.Children[0].Children[1].InnerText.Replace("套", ""));
                    me.BuildingAreaAll = double.Parse(info.Children[1].Children[1].InnerText.Replace("m2", ""));
                }
                catch { }
                me.Save(); this.NavToNext(); return;
            }
            else { me.Save(); this.NavToNext(); return; }
        }
Пример #8
0
        void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (e.Url != Document.Url) return;
            if (e.Url.ToString() == "about:blank")
            {
                page++;
                if (pageMax > 0 && page > pageMax) { this.NavToNext(); return; }
                string para = "currentPage=" + page;
                HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://222.186.197.52:9080/estate2/olestate/queryPjtList.action");
                req.Method = "POST";
                req.ContentType = "application/x-www-form-urlencoded";
                byte[] byteArray = Encoding.GetEncoding("GBK").GetBytes(para);
                req.ContentLength = byteArray.Length;
                Stream newStream = req.GetRequestStream();
                newStream.Write(byteArray, 0, byteArray.Length);
                newStream.Close();

                string result = string.Empty;
                try
                {
                    HttpWebResponse response = (HttpWebResponse)req.GetResponse();
                    StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.Default);

                    result = sr.ReadToEnd();
                    sr.Close();
                    response.Close();
                }
                catch { this.NavToNext(); return; }
                if (result == string.Empty) { this.NavToNext(); return; }

                Document.Write(result);

                if (pageMax < 0)
                {
                    try
                    {
                        Regex reg = new Regex("共\\((\\d+)\\)页");
                        Match m = reg.Match(GetElementByClassName("pages_btns").InnerText);
                        pageMax = int.Parse(m.Groups[1].Value);
                    }
                    catch { pageMax = 10; }
                }

                foreach (HtmlElement link in Document.GetElementsByTagName("a"))
                {
                    try
                    {
                        string strLink = link.GetAttribute("href");
                        if (strLink.StartsWith("about:/estate2/olestate/getPjtPrep.action"))
                        {
                            strLink = strLink.Replace("about:", "http://222.186.197.52:9080");
                            if (!UrlInLinkList(strLink) && !Fn.IsExistEstUrl(strLink)) listLink.Add(new KeyValuePair<string, object>(strLink, link.InnerText));
                        }
                    }
                    catch { }
                }

                this.Navigate("about:blank");
                return;
            }

            try
            {
                Model_Estate me = new Model_Estate("镇江");
                me.SourceLink = linkCurrent.Key;
                me.EstName = linkCurrent.Value.ToString();
                me.EstNum = me.SourceLink.Split('=')[1].Split('&')[0];

                HtmlElement info = Document.GetElementById("table1").Children[0];
                me.DistrictName = info.Children[2].Children[3].InnerText;
                me.PlateName = info.Children[3].Children[1].InnerText;
                me.BuildingAreaAll = double.Parse(info.Children[3].Children[3].InnerText);
                me.GroundAreaAll = double.Parse(info.Children[5].Children[3].InnerText);
                me.CompletionTime = info.Children[6].Children[3].InnerText;
                me.EstIntroduction = info.Children[7].Children[1].InnerText;
                me.Save();
            }
            catch { }

            this.NavToNext();
        }
Пример #9
0
        void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (e.Url != Document.Url) return;
            Model_Estate me = new Model_Estate("无锡");

            if (e.Url.ToString().StartsWith(url))
            {
                HtmlElementCollection tableList = Document.Body.Children;

                if (pageMax == -1)
                {
                    HtmlElement divNumList = GetElementByClassName("numList", "div");
                    Regex regTmp = new Regex("^第 ([\\d]+) 页$");
                    foreach (HtmlElement item in divNumList.GetElementsByTagName("a"))
                    {
                        Match mTmp = regTmp.Match(item.GetAttribute("title"));
                        if (mTmp.Success)
                        {
                            int intTmp = int.Parse(mTmp.Groups[1].Value);
                            if (intTmp > pageMax) pageMax = intTmp;
                        }
                    }
                }
                foreach (HtmlElement table in tableList)
                {
                    if (table.TagName.ToLower() != "table") continue;
                    try
                    {
                        HtmlElement el =table.GetElementsByTagName("a")[1];
                        string link = el.GetAttribute("href");
                        Match mLink = regLink.Match(link);
                        if (!mLink.Success) continue;
                        string EstNum = mLink.Groups[1].Value;
                        string[] tmp = {EstNum, el.InnerText.Trim() };
                        bool isExist = me.IsExist(EstNum);
                        if (!listLink.Contains(new KeyValuePair<string, object>(link, tmp))&&!isExist) listLink.Add(new KeyValuePair<string, object>(link, tmp));
                        if (isExist) pageMax = Math.Min(page + 5, pageMax);
                    }
                    catch { continue; }
                }

                this.NavToNextPage();
                return;
            }

            me.EstNum = (linkCurrent.Value as string[])[0];
            me.EstName = (linkCurrent.Value as string[])[1];
            try
            {
                HtmlElement panel = Document.GetElementById("divmenuinfo1").Children[0].Children[0].Children[0].Children[2];

                try { me.SaleTele = panel.Children[5].Children[0].Children[0].Children[1].Children[0].InnerText; } catch { }

                try
                {
                    string[] tmp=panel.Children[0].Children[0].Children[0].Children[1].InnerText.Replace(" ", "").Replace(" ", "").Trim().Trim(')').Split('(');
                    me.DistrictName = tmp[0];
                    me.PlateName = tmp[1];
                }
                catch { }

                try
                {
                    HtmlElement tbody = panel.Children[1].Children[0];
                    me.EstAddr = tbody.Children[0].Children[1].InnerText;
                    me.OpeningTime = tbody.Children[1].Children[1].InnerText;
                    me.HandoverTime = tbody.Children[2].Children[1].InnerText;
                }
                catch { }

                try
                {
                    HtmlElement tbody = panel.Children[2].Children[0];
                    me.EstUsage = tbody.Children[0].Children[1].InnerText;
                }
                catch { }

                try { me.Developer = panel.Children[3].Children[0].Children[0].Children[1].InnerText; }
                catch { }

                try
                {
                    HtmlElement tbody = Document.GetElementById("hs_sellNum").Parent.Parent;
                    try {
                        MatchCollection mc = regNumber.Matches(tbody.Children[0].Children[1].InnerText);
                        foreach (Match m in mc)
                        {
                            me.CountAll += int.Parse(m.Value);
                        }
                        //me.CountAll = int.Parse(tbody.Children[0].Children[1].InnerText);
                    }
                    catch { }

                    try
                    {
                        MatchCollection mc = regNumber.Matches(tbody.Children[0].Children[3].InnerText);
                        foreach (Match m in mc)
                        {
                            me.CountSold += int.Parse(m.Value);
                        }
                        me.CountSold = me.CountAll - me.CountSold;
                        if (me.CountSold < 0) me.CountSold = 0;
                    }
                    catch { }

                    me.GreeningRate = tbody.Children[1].Children[1].InnerText;
                    me.PlotRatio = tbody.Children[1].Children[3].InnerText;
                    me.PropertyCompany = tbody.Children[2].Children[1].InnerText;
                    me.PropertyFee = tbody.Children[2].Children[3].InnerText;
                    me.SaleAgent = tbody.Children[3].Children[1].InnerText;
                    me.GroundName = tbody.Children[3].Children[3].InnerText;

                    try
                    {
                        tbody = tbody.Parent.NextSibling.Children[0];
                        me.SaleAddr = tbody.Children[0].Children[1].InnerText;
                        me.Traffic = tbody.Children[1].Children[1].InnerText;
                    }
                    catch { }
                }
                catch { }

                me.EstIntroduction = Document.GetElementById("tabtabm21").InnerText;
                me.DevIntroduction = Document.GetElementById("tabtabm22").InnerText;
                me.EstFacility = Document.GetElementById("tabtabm23").InnerText;
                me.SrdFacility = Document.GetElementById("tabtabm24").InnerText;

                me.SourceLink = linkCurrent.Key;
                int estId= me.Save(true);

                //开始计算报价信息
                Model_Estate_Price mep = new Model_Estate_Price(estId);
                mep.SourceLink = "http://www.wxhouse.com";
                mep.SourceName = "无锡房地产市场网";
                panel = Document.GetElementById("divmenuinfo3").Children[0].Children[0].Children[0].Children[0].Children[0].Children[0];
                Regex regPrice = new Regex("(\\d+(元/㎡)?[-~])?(\\d+)元/㎡");
                foreach (HtmlElement tr in panel.Children)
                {
                    try { mep.PriceDate = DateTime.Parse(tr.Children[0].InnerText.Trim()); }
                    catch { continue; }
                    if (tr.Children[1].InnerText == null) continue;
                    string[] arrInfo = tr.Children[1].InnerText.Replace(";",";").Split(';');
                    foreach (string info in arrInfo)
                    {
                        try
                        {
                            if (info.IndexOf(':') > 0)
                            {
                                mep.EstUsage = info.Substring(0, info.IndexOf(':'));
                            }
                            else mep.EstUsage = "商品房";

                            MatchCollection mc = regPrice.Matches(info);
                            if (mc.Count == 0) continue;
                            mep.PriceMin = 0;
                            mep.PriceMax = 0;
                            foreach (Match m in mc)
                            {
                                int min = 0;
                                try
                                {
                                    min = int.Parse(m.Groups[1].Value.Replace("-", "").Replace("~", "").Replace("元/㎡", ""));
                                }
                                catch { }
                                int max = int.Parse(m.Groups[3].Value);

                                if ((mep.PriceMin > min || mep.PriceMin == 0) && min > 0) mep.PriceMin = min;
                                if (mep.PriceMin > max || mep.PriceMin == 0) mep.PriceMin = max;
                                if (mep.PriceMax < max) mep.PriceMax = max;

                            }
                            mep.Remark = info;
                            mep.Save(false);
                        }
                        catch { }
                    }
                }
            }
            catch(Exception ex) {
                Program.MainForm.AddMessage("错误!无锡楼盘数据抓取错误。链接:"+me.SourceLink+"。楼盘Id:" + me.EstNum + "。错误消息:"+ex.Message);
            }
            this.NavToNext();
        }
Пример #10
0
        void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (e.Url.ToString() != Document.Url.ToString()) return;
            if (e.Url.ToString().StartsWith("http://newhouse.ntfdc.net/house_search.aspx?pageindex="))
            {
                if (pageMax < 0)
                {
                    HtmlElement divPage = null;
                    foreach (HtmlElement item in Document.GetElementsByTagName("div"))
                    {
                        try
                        {
                            string cls = item.GetAttribute("classname");
                            if (cls == "multipage") { divPage = item; break; }
                        }
                        catch { }
                    }
                    if (divPage != null)
                    {
                        try { pageMax = int.Parse(divPage.Children[divPage.Children.Count - 2].InnerText.Trim()); }
                        catch { pageMax = 10; }
                    }
                    else pageMax = 10;
                }

                HtmlElement ulLP = null;
                foreach (HtmlElement item in Document.GetElementsByTagName("div"))
                {
                    try
                    {
                        string cls = item.GetAttribute("classname");
                        if (cls == "lplist") { ulLP = item.Children[0]; break; }
                    }
                    catch { }
                }

                if (ulLP == null) { this.NavToNext(); return; }
                foreach (HtmlElement li in ulLP.Children)
                {
                    try
                    {
                        HtmlElement link = li.Children[1].Children[0];
                        string strLink = link.GetAttribute("href");
                        if (!UrlInLinkList(strLink) && !Fn.IsExistEstUrl(strLink)) listLink.Add(new KeyValuePair<string, object>(strLink, link.InnerText));
                    }
                    catch { }
                }
                this.NavToNextPage();
                return;
            }

            try
            {
                Model_Estate me = new Model_Estate("南通");
                me.SourceLink = linkCurrent.Key;
                me.PublicName = linkCurrent.Value.ToString();
                me.EstNum = me.SourceLink.Split('=')[1];

                HtmlElement house_info2 = GetElementByClassName("house_info2", "div");

                HtmlElement info = house_info2.Children[0].Children[0];
                me.EstName = info.Children[0].InnerText.Split(':')[1];
                me.DecorationLevel = info.Children[1].InnerText.Split(':')[1];
                me.CountAll = int.Parse(info.Children[2].InnerText.Split(':')[1].Replace("套",""));
                me.Developer = info.Children[4].InnerText.Split(':')[1];
                me.DistrictName = info.Children[5].Children[1].InnerText;
                me.EstAddr = info.Children[6].InnerText.Split(':')[1];

                me.SaleTele = house_info2.Children[1].Children[0].Children[2].InnerText;

                info = house_info2.Children[3].Children[0];
                me.OpeningTime = info.Children[0].InnerText.Split(':')[1];
                me.HandoverTime = info.Children[1].InnerText.Split(':')[1];
                me.GroundAreaAll = double.Parse(info.Children[2].InnerText.Split(':')[1].Replace("平方米", ""));
                me.BuildingAreaAll = double.Parse(info.Children[3].InnerText.Split(':')[1].Replace("平方米", ""));
                me.PlotRatio = info.Children[4].InnerText.Split(':')[1];
                me.GreeningRate = info.Children[5].Children[1].InnerText;
                me.PropertyFee = info.Children[6].InnerText.Split(':')[1];
                me.PropertyCompany = info.Children[7].InnerText.Split(':')[1];
                me.EstUsage = info.Children[8].InnerText.Split(':')[1];
                me.SaleAddr = info.Children[9].InnerText.Split(':')[1];
                me.SaleAgent = info.Children[10].InnerText.Split(':')[1];
                me.Builder = info.Children[11].InnerText.Split(':')[1];

                info = GetElementByClassName("house_project", "div");
                if (info != null)
                {
                    try
                    {
                        info = info.Children[1];
                        me.EstIntroduction = info.Children[0].GetAttribute("data-value");
                        me.SrdFacility = info.Children[1].GetAttribute("data-value");
                        me.Traffic = info.Children[2].GetAttribute("data-value");
                        me.DevIntroduction = info.Children[4].GetAttribute("data-value");
                        me.Remark = info.Children[5].GetAttribute("data-value");
                    }
                    catch { }
                }
                me.Save();
            }
            catch { }

            this.NavToNext();
        }
Пример #11
0
        void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (e.Url != Document.Url) return;
            if (e.Url.ToString().StartsWith(linkList))
            {
                HtmlElement divList = GetElementByClassName("tjlp_left", "div");
                if (divList == null||divList.Children.Count==0)
                {
                    this.NavToNext();
                    return;
                }

                foreach (HtmlElement item in divList.Children)
                {
                    try
                    {
                        if (item.GetAttribute("classname") != "tjlp_left_center") continue;
                        HtmlElement link = item.Children[1].Children[0].Children[0];
                        string strLink = link.GetAttribute("href");
                        listLink.Add(new KeyValuePair<string, object>(strLink, strLink.Split('=')[1]));
                    }
                    catch { }
                }
                this.NavToNextPage();
                return;
            }

            try
            {
                Model_Estate me = new Model_Estate("宜兴");
                me.EstNum = linkCurrent.Value.ToString();
                me.EstName = GetElementByClassName("tjlp_listshow_left_center_bg1_1", "span").InnerText;
                me.SaleTele = GetElementByClassName("tjlp_listshow_left_center_bg1_4", "span").InnerText;

                HtmlElement tbInfo = GetElementByClassName("tjlp_listshow_left_center_bg2_right", "div",0).Children[0].Children[0];
                me.DistrictName = tbInfo.Children[0].Children[1].InnerText;
                me.PlateName = tbInfo.Children[0].Children[3].InnerText;
                me.OpeningTime = tbInfo.Children[1].Children[1].InnerText;
                me.HandoverTime = tbInfo.Children[1].Children[3].InnerText;
                me.EstAddr = tbInfo.Children[2].Children[1].InnerText;
                me.EstUsage = tbInfo.Children[3].Children[1].InnerText;
                me.Developer = tbInfo.Children[5].Children[1].InnerText;

                tbInfo = GetElementByClassName("tjlp_lpxx_left_center_bg2_right", "div", 0).Children[0].Children[0];
                try { me.CountAll = int.Parse(tbInfo.Children[0].Children[1].InnerText.Split(' ')[0].Trim()); }
                catch { }
                me.GreeningRate = tbInfo.Children[1].Children[1].InnerText;
                me.PlotRatio = tbInfo.Children[1].Children[3].InnerText;
                me.PropertyCompany = tbInfo.Children[2].Children[1].InnerText;
                me.PropertyFee = tbInfo.Children[2].Children[3].InnerText;
                me.SaleAgent = tbInfo.Children[3].Children[1].InnerText;
                me.SaleAddr = tbInfo.Children[4].Children[1].InnerText;
                me.Traffic = tbInfo.Children[5].Children[1].InnerText;

                tbInfo = GetElementByClassName("xfpd_tjlpshowncont_tab", "div");
                me.EstIntroduction = tbInfo.Children[0].GetElementsByTagName("textarea")[0].GetAttribute("value");
                me.DevIntroduction = tbInfo.Children[1].GetElementsByTagName("textarea")[0].GetAttribute("value");
                me.EstFacility = tbInfo.Children[2].GetElementsByTagName("textarea")[0].GetAttribute("value");
                me.SrdFacility = tbInfo.Children[3].GetElementsByTagName("textarea")[0].GetAttribute("value");

                me.Save();
            }
            catch { }

            this.NavToNext();
        }