Example #1
0
 /// <summary>
 /// 初始化许可证上市量类
 /// </summary>
 /// <param name="mp">许可证</param>
 public Model_PermitSale(Model_Permit mp)
 {
     this._mp = mp;
 }
Example #2
0
 /// <summary>
 /// 初始化许可证成交量类
 /// </summary>
 /// <param name="mp">许可证</param>
 public Model_PermitSold(Model_Permit mp)
 {
     this._mp = mp;
 }
Example #3
0
        void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (e.Url != Document.Url) return;
            Model_Permit mp = new Model_Permit("无锡");

            if (e.Url.ToString().StartsWith("http://www.wxhouse.com/newhouse/bainfo.html?houseid="))
            {
                foreach (HtmlElement elLink in Document.GetElementsByTagName("a"))
                {
                    try
                    {
                        string strLink = elLink.GetAttribute("href");
                        string strPermitName = elLink.InnerText.Trim();

                        if (strLink.StartsWith("http://pub.wxlife.cn/BuildInfo.pub?blid="))
                        {
                            string strPermitNum=strLink.Split('=')[1];
                            if (mp.IsExist(strPermitNum)) continue;
                            //strLink = "http://pub.wxlife.cn/ifrm_BuildStat.pub?blid=" + strLink.Split('=')[1];
                            string strDate = elLink.Parent.NextSibling.InnerText.Split(':')[1];
                            listLink.Add(new KeyValuePair<string, object>(strLink, new string[] { listEstNum[indexEstNum], strPermitName, strDate }));
                        }
                    }
                    catch { }
                }
                this.NavToNextEstate();
                return;
            }

            mp.SourceLink = Document.Url.ToString();
            try
            {
                mp.EstNum = (linkCurrent.Value as string[])[0];
                mp.PermitNum = linkCurrent.Key.Split('=')[1];
                mp.PermitName = (linkCurrent.Value as string[])[1];
                mp.IssueDate = DateTime.Parse((linkCurrent.Value as string[])[2]);

                HtmlElement tbody = Document.Window.Frames[0].Document.GetElementById("info").Children[0];
                try { mp.ConstructionDate = DateTime.Parse(tbody.Children[17].Children[1].InnerText); }
                catch { }
                try { mp.CompletionDate = DateTime.Parse(tbody.Children[18].Children[1].InnerText); }
                catch { }
                try { mp.SaleArea = double.Parse(tbody.Children[20].Children[1].InnerText.Split(' ')[0]); }
                catch { }
                try { mp.SaleCount = int.Parse(tbody.Children[22].Children[1].InnerText); }
                catch { }

                mp.Save();

                Model_PermitSale mps = new Model_PermitSale(mp);
                mps.SaleArea = mp.SaleArea;
                mps.SaleCount = mp.SaleCount;
                mps.Save(true);

                Model_PermitSold mpsd = new Model_PermitSold(mp);
                foreach (HtmlElement item in Document.GetElementsByTagName("td"))
                {
                    if (item.InnerText == "已 售:")
                    {
                        try
                        {
                            mpsd.SoldCount = int.Parse(item.NextSibling.InnerText.Split(' ')[0].Replace("套",""));
                        }
                        catch { }
                        break;
                    }
                }
                if (mpsd.SoldCount > 0) mpsd.Save(true);
            }
            catch(Exception ex) {
                Program.MainForm.AddMessage("错误!无锡许可证数据抓取错误。链接:" + mp.SourceLink + "。错误消息:" + ex.Message);
            }

            this.NavToNext();
        }