Beispiel #1
0
        void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (e.Url != Document.Url) return;
            try
            {
                HtmlElement tbody = Document.Window.Frames["f_view"].Document.GetElementById("tblparcel").FirstChild;
                Model_Ground mg = new Model_Ground("淮安");
                for (int i = 2; i < tbody.Children.Count-1; i++)
                {
                    try
                    {
                        HtmlElement tr = tbody.Children[i];
                        mg.GroundNum = tr.Children[0].InnerText.Trim();

                        if (!mg.IsExist(mg.GroundNum)) continue;

                        mg.PlotRatio = tr.Children[4].InnerText;
                        mg.BuildingDensity = tr.Children[5].InnerText;
                        mg.GreeningRate = tr.Children[6].InnerText;
                        mg.BidBond = Convert.ToDouble(tr.Children[8].InnerText.Trim()) * 10000;
                        mg.StartingPrice = Convert.ToDouble(tr.Children[9].InnerText.Trim()) * 10000;
                        mg.IncreaseRate = tr.Children[10].InnerText.Trim();

                        mg.Save(true, new List<string>() { "PlotRatio", "BuildingDensity", "GreeningRate", "BidBond", "StartingPrice", "IncreaseRate" });
                    }
                    catch { }

                }
            }
            catch { }
            this.NavToNext();
        }
Beispiel #2
0
        void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (e.Url != Document.Url) return;
            if (e.Url.ToString() == "http://gtj.jiangyin.gov.cn/jygt/sitePages/channelPages/135034050062404.html")
            {
                this.timer2.Interval = 3000;
                this.timer2.Start();
                return;
            }

            Model_Ground mg = new Model_Ground("江阴");
            //开始计算信息包括的字段
            List<string> arrCol = new List<string>();
            HtmlElement tRow = null;

            List<HtmlElement> listTRowSub = new List<HtmlElement>();
            List<int> listSubIndex = new List<int>();

            int headRowSpan = 1;
            try
            {
                foreach (HtmlElement td in Document.GetElementById("lk_wcms_edit_pictext701content").GetElementsByTagName("td"))
                {
                    try
                    {
                        string str = td.InnerText.Replace("\n", "").Replace("\r", "").Replace(" ", "").Replace(" ", "").Trim();
                        if (str == "宗地编号" || str == "地块编号")
                        {
                            tRow = td.Parent;
                            break;
                        }
                    }
                    catch { }
                }

                foreach (HtmlElement td in tRow.Children)
                {
                    int rowSpan = int.Parse(td.GetAttribute("rowspan"));
                    if (rowSpan > headRowSpan) headRowSpan = rowSpan;
                }

                for (int i = 1; i < headRowSpan; i++)
                {
                    listTRowSub.Add(listTRowSub.Count == 0 ? tRow.NextSibling : listTRowSub[listTRowSub.Count - 1].NextSibling);
                    listSubIndex.Add(0);
                }

                foreach (HtmlElement td in tRow.Children)
                {
                    int rowSpan = int.Parse(td.GetAttribute("rowspan"));
                    int colSpan = int.Parse(td.GetAttribute("colspan"));
                    string str = td.InnerText.Replace("\n", "").Replace("\r", "").Replace(" ", "").Replace(" ", "").Trim();
                    KeyValuePair<string, string> kvCol;
                    string strTop = regColNameFilter.Replace(str, "");
                    if (colSpan == 1)
                    {
                        str = strTop;
                        for (int i = rowSpan-1; i < headRowSpan-1; i++)
                        {
                            str += listTRowSub[i].Children[listSubIndex[i]].InnerText.Replace("\n", "").Replace("\r", "").Replace(" ", "").Replace(" ", "").Trim();
                            listSubIndex[i]++;
                        }
                        try
                        {
                            kvCol = listColName.FindAll(delegate(KeyValuePair<string, string> kv) { return kv.Key == str; })[0];
                            arrCol.Add(kvCol.Value);
                        }
                        catch
                        {
                            arrCol.Add("");
                        }
                        continue;
                    }

                    HtmlElement tRowSub = listTRowSub[rowSpan - 1];
                    for (int i = 0; i < colSpan; i++)
                    {
                        str = strTop;
                        for (int j = rowSpan - 1; j < headRowSpan - 1; j++)
                        {
                            str += listTRowSub[j].Children[listSubIndex[j]].InnerText.Replace("\n", "").Replace("\r", "").Replace(" ", "").Replace(" ", "").Trim();
                            listSubIndex[j]++;
                        }
                        //str = strTop + tRowSub.Children[i + listSubIndex[rowSpan-1]].InnerText.Replace("\n", "").Replace("\r", "").Replace(" ", "").Replace(" ", "").Trim();
                        //str = regColNameFilter.Replace(str, "");
                        try
                        {
                            kvCol = listColName.FindAll(delegate(KeyValuePair<string, string> kv) { return kv.Key == str; })[0];
                            arrCol.Add(kvCol.Value);
                        }
                        catch
                        {
                            arrCol.Add("");
                            continue;
                        }
                    }
                    //listSubIndex[rowSpan - 1] += colSpan;
                }
            }
            catch { this.NavToNext(); return; }

            mg.ClinchLink = Document.Url.ToString().Replace(".html",".jsp");

            int[] arrRowSpan = new int[arrCol.Count];

            try
            {
                Type type = typeof(Model_Ground);
                HtmlElement tr = (listTRowSub.Count == 0 ? tRow : listTRowSub[listTRowSub.Count-1]).NextSibling;
                while (tr != null)
                {
                    int offset = 0;
                    for (int i = 0; i < arrCol.Count; i++)
                    {
                        int rowSpan = 0;
                        try
                        {
                            rowSpan = int.Parse(tr.Children[i - offset].GetAttribute("rowspan")) - 1;
                        }
                        catch { }

                        if (arrCol[i] == "" || arrCol[i] == null)
                        {
                            if (arrRowSpan[i] > 0)
                            {
                                offset++;
                                arrRowSpan[i]--;
                            }
                            if (rowSpan > 0) arrRowSpan[i] = rowSpan;
                            continue;
                        }

                        if (arrRowSpan[i] > 0)
                        {
                            offset++;
                            arrRowSpan[i]--;
                            continue;
                        }

                        if (rowSpan > 0) arrRowSpan[i] = rowSpan;

                        string strValue = tr.Children[i - offset].InnerText;
                        if (strValue != null)
                        {
                            strValue = strValue.Replace("\n", "").Replace("\r", "").Replace(" ", "").Replace(" ", "").Trim();
                        }
                        FieldInfo info = type.GetField(arrCol[i]);
                        Type t = info.FieldType;

                        try
                        {
                            if (t == typeof(int))
                            {
                                try
                                {
                                    info.SetValue(mg, int.Parse(strValue));
                                }
                                catch {
                                    info.SetValue(mg, 0);
                                }
                            }
                            else if (t == typeof(double))
                            {
                                try
                                {
                                    info.SetValue(mg, double.Parse(strValue));
                                }
                                catch {
                                    info.SetValue(mg, 0);
                                }
                            }
                            else if (t == typeof(DateTime))
                            {
                                if (strValue.IndexOf("~") >= 0) strValue = strValue.Split('~')[1];
                                info.SetValue(mg, DateTime.Parse(strValue));
                            }
                            else
                            {
                                info.SetValue(mg, strValue);
                            }
                        }
                        catch { }
                    }
                    mg.GroundNum = mg.GroundNum.Replace("澄地", "").Trim();
                    mg.ClinchPrice *= 10000;
                    if(mg.ClinchPrice>0) mg.Update(listUpdateFields);
                    tr = tr.NextSibling;
                }
            }
            catch (Exception ex)
            {
                Program.MainForm.AddMessage("错误!江阴地块成交数据抓取错误。链接:" + mg.ClinchLink + "错误Id:" + mg.GroundNum + "。错误消息:" + ex.Message);
            }

            this.NavToNext();
        }
Beispiel #3
0
        void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (e.Url != Browser.Url) return;
            if (e.Url.ToString().StartsWith("http://www.landjs.com/web/cjgs_list.aspx"))
            {
                HtmlElement tbody=null;
                try { tbody = Document.GetElementById("GridView1").Children[0]; }
                catch { }
                if (tbody == null || tbody.Children.Count <= 1)
                {
                    this.NavToNext(); return;
                }

                for (int i = 1; i < tbody.Children.Count; i++)
                {
                    try
                    {
                        HtmlElement a = tbody.Children[i].Children[2].Children[0];
                        string strLink = a.GetAttribute("href");
                        string groundNum = a.InnerText.Trim();

                        if (Fn.GetDT_PgSQL("select * from ground_info where cityid='" + cityId + "' and groundnum=" + q + groundNum + q).Rows.Count > 0) continue;
                        listLink.Add(new KeyValuePair<string, object>(strLink, groundNum));
                    }
                    catch { }
                }
                this.NavToNextPage();
                return;
            }
            else if (e.Url.ToString().StartsWith("http://www.landjs.com/web/cjgs_view.aspx"))
            {
                try
                {
                    Model_Ground mg = new Model_Ground(CityName);
                    try { mg.GroundNum = Document.GetElementById("PARCEL_NO").InnerText.Trim(); }
                    catch { }

                    try { mg.ListingNum = Document.GetElementById("AFFICHE_NO").InnerText.Trim(); }
                    catch { }

                    try { mg.GLocation = Document.GetElementById("LAND_POSITION").InnerText.Trim(); }
                    catch { }

                    try { mg.DistrictName = Document.GetElementById("XZQ_DM").InnerText.Trim(); }
                    catch { }

                    try { mg.GArea = Convert.ToDouble(Document.GetElementById("REMISE_AREA").InnerText.Trim()); }
                    catch { }

                    try { mg.GUsage = Document.GetElementById("LAND_USE").InnerText.Trim(); }
                    catch { }

                    try { mg.TransferYear = Document.GetElementById("USE_YEAR").InnerText.Trim(); }
                    catch { }

                    try { mg.TransferWay = Document.GetElementById("REMISE_TYPE").InnerText.Trim(); }
                    catch { }

                    try { mg.StartingPrice = Convert.ToDouble(Document.GetElementById("START_PRICE").InnerText.Trim()) * 10000; }
                    catch { }

                    try { mg.ClinchPrice = Convert.ToDouble(Document.GetElementById("PRICE").InnerText.Trim()) * 10000; }
                    catch { }

                    try { mg.ClinchDate = Convert.ToDateTime(Document.GetElementById("BARGAIN_DATE").InnerText.Trim()); }
                    catch { }

                    try { mg.Buyer = Document.GetElementById("ALIENEE").InnerText.Trim(); }
                    catch { }

                    try { mg.ListingDate = Convert.ToDateTime(Document.GetElementById("KSRQ").InnerText.Trim()); }
                    catch { }

                    try { mg.GCondition = Document.GetElementById("DELIVER_TERM").InnerText.Trim(); }
                    catch { }

                    string strSourceLink = "";
                    try
                    {
                        strSourceLink = Document.GetElementById("AFFICHE_NO").FirstChild.GetAttribute("href");
                        mg.SourceLink = strSourceLink;
                    }
                    catch { }

                    mg.ClinchLink = this.linkCurrent.Key;
                    if (mg.TransferWay == "") mg.TransferWay = listTransferWay[xmlx];

                    mg.Save();

                    if (strSourceLink != null && strSourceLink != "")
                    {
                        this.Navigate(strSourceLink);
                    }
                    else this.NavToNext();

                }
                catch { this.NavToNext(); }
            }
            else
            {
                try
                {
                    HtmlElement tbody = Document.Window.Frames["f_view"].Document.GetElementById("tblparcel").FirstChild;
                    Model_Ground mg = new Model_Ground(CityName);
                    mg.GroundNum = linkCurrent.Value.ToString();
                    for (int i = 2; i < tbody.Children.Count - 1; i++)
                    {
                        try
                        {
                            HtmlElement tr = tbody.Children[i];
                            string groundNum = tr.Children[0].InnerText.Trim();
                            if (groundNum != mg.GroundNum) continue;

                            if (!mg.IsExist(mg.GroundNum)) break;

                            mg.PlotRatio = tr.Children[4].InnerText;
                            mg.BuildingDensity = tr.Children[5].InnerText;
                            mg.GreeningRate = tr.Children[6].InnerText;
                            mg.BidBond = Convert.ToDouble(tr.Children[8].InnerText.Trim()) * 10000;
                            mg.StartingPrice = Convert.ToDouble(tr.Children[9].InnerText.Trim()) * 10000;
                            mg.IncreaseRate = tr.Children[10].InnerText.Trim();

                            mg.Save(true, new List<string>() { "PlotRatio", "BuildingDensity", "GreeningRate", "BidBond", "StartingPrice", "IncreaseRate" });
                        }
                        catch { }

                    }
                }
                catch { }
                this.NavToNext();
            }
        }
Beispiel #4
0
        void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (e.Url != Browser.Url) return;
            if (e.Url.ToString().StartsWith("http://www.landjs.com/web/cjgs_list.aspx"))
            {
                HtmlElement tbody = Document.GetElementById("GridView1").Children[0];
                if (tbody == null||tbody.Children.Count<=1)
                {
                    this.NavToNext(); return;
                }

                for (int i = 1; i < tbody.Children.Count; i++)
                {
                    try
                    {
                        HtmlElement a = tbody.Children[i].Children[2].Children[0];
                        string strLink = a.GetAttribute("href");
                        string groundNum = a.InnerText.Trim();

                        if (Fn.GetDT_PgSQL("select * from ground_info where cityid='" + cityId + "' and groundnum=" + q + groundNum + q).Rows.Count > 0) continue;
                        listLink.Add(new KeyValuePair<string, object>(strLink, groundNum));
                    }
                    catch { }
                }
                this.NavToNextPage();
                return;
            }

            try
            {
                Model_Ground mg = new Model_Ground("淮安");
                try { mg.GroundNum = Document.GetElementById("PARCEL_NO").InnerText.Trim(); }
                catch { }

                try { mg.ListingNum = Document.GetElementById("AFFICHE_NO").InnerText.Trim(); }
                catch { }

                try { mg.GLocation = Document.GetElementById("LAND_POSITION").InnerText.Trim(); }
                catch { }

                try { mg.DistrictName = Document.GetElementById("XZQ_DM").InnerText.Trim(); }
                catch { }

                try { mg.GArea = Convert.ToDouble(Document.GetElementById("REMISE_AREA").InnerText.Trim()); }
                catch { }

                try { mg.GUsage = Document.GetElementById("LAND_USE").InnerText.Trim(); }
                catch { }

                try { mg.TransferYear = Document.GetElementById("USE_YEAR").InnerText.Trim(); }
                catch { }

                try { mg.TransferWay = Document.GetElementById("REMISE_TYPE").InnerText.Trim(); }
                catch { }

                try { mg.StartingPrice = Convert.ToDouble(Document.GetElementById("START_PRICE").InnerText.Trim()) * 10000; }
                catch { }

                try { mg.ClinchPrice = Convert.ToDouble(Document.GetElementById("PRICE").InnerText.Trim()) * 10000; }
                catch { }

                try { mg.ClinchDate = Convert.ToDateTime(Document.GetElementById("BARGAIN_DATE").InnerText.Trim()); }
                catch { }

                try { mg.Buyer = Document.GetElementById("ALIENEE").InnerText.Trim(); }
                catch { }

                try { mg.ListingDate = Convert.ToDateTime(Document.GetElementById("KSRQ").InnerText.Trim()); }
                catch { }

                try { mg.GCondition = Document.GetElementById("DELIVER_TERM").InnerText.Trim(); }
                catch { }

                try { mg.SourceLink = Document.GetElementById("AFFICHE_NO").FirstChild.GetAttribute("href"); }
                catch { }

                mg.ClinchLink = this.linkCurrent.Key;

                mg.Save();
            }
            catch { }
            this.NavToNext();
        }
Beispiel #5
0
        void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (e.Url != Document.Url) return;
            if (regUrl.IsMatch(e.Url.ToString()))
            {
                foreach (HtmlElement elLink in Document.GetElementsByTagName("a"))
                {
                    try
                    {
                        string strLink = elLink.GetAttribute("href");
                        if (regLink.IsMatch(strLink))
                        {
                            listLink.Add(new KeyValuePair<string, object>(strLink, elLink.InnerText));
                        }
                    }
                    catch { }
                }

                try
                {
                    HtmlElement btnNext = Document.Body.Children[2].GetElementsByTagName("input")[2];
                    if (bool.Parse(btnNext.GetAttribute("disabled"))) this.NavToNext();
                    else
                    {
                        page++;
                        this.Navigate("http://gtj.wuxi.gov.cn/BA13/D/05/index_"+page.ToString()+".shtml");
                    }
                }
                catch { this.NavToNext(); }
                return;
            }

            Model_Ground mg = new Model_Ground("无锡");
            mg.ClinchLink = Document.Url.ToString();
            //开始计算成交日期
            foreach (HtmlElement td in Document.GetElementsByTagName("td"))
            {
                if (td.InnerText!=null&&td.InnerText.Trim() == "公开日期")
                {
                    try
                    {
                        mg.ClinchDate = DateTime.Parse(td.NextSibling.InnerText);
                    }
                    catch { }
                    break;
                }
            }

            HtmlElement zoom = Document.GetElementById("Zoom");
            HtmlElement tRow = null;
            foreach (HtmlElement td in zoom.GetElementsByTagName("td"))
            {
                try
                {
                    string str = td.InnerText.Replace("\n","").Replace("\r","").Replace(" ","").Replace(" ","").Trim();
                    if (str == "编号" || str == "地块编号")
                    {
                        tRow = td.Parent;
                        break;
                    }
                }
                catch { }
            }

            //开始计算每一条成交信息
            mg.ClinchLink = linkCurrent.Key;
            try
            {
                if (tRow != null)
                {

                    List<string> arrCol = new List<string>();
                    foreach (HtmlElement td in tRow.Children)
                    {
                        string str = td.InnerText.Replace("\n", "").Replace("\r", "").Replace(" ", "").Replace(" ", "").Trim();
                        str = regColNameFilter.Replace(str, "");
                        KeyValuePair<string, string> kvCol;
                        try
                        {
                            kvCol = listColName.FindAll(delegate(KeyValuePair<string, string> kv) { return kv.Key == str; })[0];
                            arrCol.Add(kvCol.Value);
                        }
                        catch
                        {
                            arrCol.Add("");
                            continue;
                        }
                    }

                    Type type = typeof(Model_Ground);
                    HtmlElement tr = tRow.NextSibling;
                    while (tr != null)
                    {
                        if (tr.Children.Count == 0) break;
                        string strGroundNum = tr.Children[0].InnerText;
                        if (strGroundNum == null) break;
                        strGroundNum = strGroundNum.Replace("\r", "").Replace("\n", "").Trim();
                        Match mGroundNum = regGroundNum.Match(strGroundNum);
                        if (!mGroundNum.Success)
                        {
                            tr = tr.NextSibling;
                            continue;
                        }
                        mg.GroundNum = mGroundNum.Value;
                        mg.ClinchPrice = 0;
                        for (int i = 0; i < arrCol.Count; i++)
                        {
                            if (arrCol[i] == "" || arrCol[i] == null) continue;
                            string strValue = tr.Children[i].InnerText;
                            if (strValue != null)
                            {
                                strValue = strValue.Replace("\n", "").Replace("\r", "").Trim();
                            }
                            FieldInfo info = type.GetField(arrCol[i]);
                            Type t = info.FieldType;
                            try
                            {
                                if (t == typeof(int))
                                {
                                    info.SetValue(mg, int.Parse(strValue));
                                }
                                else if (t == typeof(double))
                                {
                                    info.SetValue(mg, double.Parse(strValue));
                                }
                                else if (t == typeof(DateTime))
                                {
                                    info.SetValue(mg, DateTime.Parse(strValue));
                                }
                                else
                                {
                                    info.SetValue(mg, strValue);
                                }
                            }
                            catch { continue; }
                        }
                        mg.ClinchPrice *= 10000;
                        if (mg.ClinchPrice > 0) mg.Save(true, listSaveFields);

                        tr = tr.NextSibling;
                    }

                }
                else
                {
                    MatchCollection mc = regSoldInfo.Matches(zoom.InnerText);
                    foreach (Match m in mc)
                    {
                        try
                        {
                            mg.GroundNum = m.Groups[1].Value;
                            mg.Buyer = m.Groups[7].Value;
                            if (mg.Buyer.IndexOf("由") >= 0) mg.Buyer = mg.Buyer.Split('由')[1];
                            mg.ClinchPrice = double.Parse(m.Groups[9].Value)*10000;
                            if (m.Groups[10].Value == "亿") mg.ClinchPrice *= 10000;
                            mg.Update(listSaveFields);
                        }
                        catch { }
                    }
                }
            }
            catch { }
            this.NavToNext();
        }
Beispiel #6
0
        void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (e.Url != Document.Url) return;
            Model_Ground mg = new Model_Ground("宜兴");
            if (e.Url.ToString().StartsWith("http://www.yxlr.gov.cn/Article/ShowClass.asp?ClassID=42&page="))
            {
                HtmlElement td = null;
                foreach (HtmlElement tb in Document.GetElementsByTagName("table"))
                {
                    if (tb.InnerText!=null&&tb.InnerText.Trim() == "招拍挂公告")
                    {
                        try
                        {
                            td = tb.Parent.Parent.NextSibling.Children[0];
                        }
                        catch { }
                        break;
                    }
                }

                if (td == null)
                {
                    this.NavToNext();
                    return;
                }

                foreach (HtmlElement elLink in td.GetElementsByTagName("a"))
                {
                    try
                    {
                        string strLink = elLink.GetAttribute("href");
                        if (regLink.IsMatch(strLink))
                        {
                            string strDate = elLink.Parent.NextSibling.InnerText;
                            if (listLink.Contains(new KeyValuePair<string, object>(strLink, strDate)))
                            {
                                this.NavToNext();
                                return;
                            }
                            if (!mg.IsExistLink(strLink)) listLink.Add(new KeyValuePair<string, object>(strLink, strDate));
                        }
                    }
                    catch { }
                }

                this.NavToNextPage();
                return;
            }

            //开始抓取详细内容

            List<string> arrCol = new List<string>();
            HtmlElement tRow = null;
            HtmlElement tRowSub = null;
            try
            {
                int subIndex = 0;
                foreach (HtmlElement td in Document.GetElementsByTagName("td"))
                {
                    try
                    {
                        string str = td.InnerText.Replace("\n", "").Replace("\r", "").Replace(" ", "").Replace(" ", "").Trim();
                        if (str == "编号" || str == "地块编号"||str=="挂牌编号")
                        {
                            tRow = td.Parent;
                            if (int.Parse(td.GetAttribute("rowspan")) > 1) tRowSub = tRow.NextSibling;
                            break;
                        }
                    }
                    catch { }
                }

                foreach (HtmlElement td in tRow.Children)
                {
                    string str = td.InnerText.Replace("\n", "").Replace("\r", "").Replace(" ", "").Replace(" ", "").Trim();
                    str = regColNameFilter.Replace(str, "");
                    int colSpan = int.Parse(td.GetAttribute("colspan"));
                    KeyValuePair<string, string> kvCol;
                    try
                    {
                        kvCol = listColName.FindAll(delegate(KeyValuePair<string, string> kv) { return kv.Key == str; })[0];
                        arrCol.Add(kvCol.Value);
                    }
                    catch
                    {
                        if (colSpan == 1)
                        {
                            arrCol.Add("");
                            continue;
                        }
                    }

                    if (colSpan == 1) continue;
                    for (int i = 0; i < colSpan; i++)
                    {
                        str = tRowSub.Children[i + subIndex].InnerText.Replace("\n", "").Replace("\r", "").Replace(" ", "").Replace(" ", "").Trim();
                        str = regColNameFilter.Replace(str, "");
                        try
                        {
                            kvCol = listColName.FindAll(delegate(KeyValuePair<string, string> kv) { return kv.Key == str; })[0];
                            arrCol.Add(kvCol.Value);
                        }
                        catch
                        {
                            arrCol.Add("");
                            continue;
                        }
                    }
                }
            }
            catch { this.NavToNext(); return; }

            mg.SourceLink = Document.Url.ToString();

            //开始计算挂牌日期
            try
            {
                mg.ListingDate = DateTime.Parse(linkCurrent.Value.ToString());
            }
            catch { }

            //开始计算每条招拍挂信息
            try
            {
                Type type = typeof(Model_Ground);
                HtmlElement tr = (tRowSub == null ? tRow : tRowSub).NextSibling;
                while (tr != null)
                {
                    for (int i = 0; i < arrCol.Count; i++)
                    {
                        if (arrCol[i] == "" || arrCol[i] == null) continue;

                        string strValue = "";
                        try
                        {
                            strValue = tr.Children[i].InnerText;
                        }
                        catch { }
                        if (strValue != null)  strValue = strValue.Trim();

                        if (arrCol[i] == "MultiPrice")
                        {
                            string[] tmp = strValue.Split('\n');
                            try { mg.StartingPrice = double.Parse(tmp[0].Trim()); }
                            catch { }
                            try { mg.BidBond = double.Parse(tmp[1].Trim()); }
                            catch { }
                            try { mg.IncreaseRate = tmp[2].Trim() + "万元"; }
                            catch { }
                        }
                        else if (arrCol[i] == "MultiRate")
                        {
                            string[] tmp = strValue.Split('\n');
                            try
                            {
                                mg.GreeningRate = tmp[0].Trim();
                                mg.PlotRatio = tmp[1].Trim();
                                mg.BuildingDensity = tmp[2].Trim();
                            }
                            catch { }
                        }
                        else
                        {
                            FieldInfo info = type.GetField(arrCol[i]);
                            Type t = info.FieldType;
                            try
                            {
                                if (t == typeof(int))
                                {
                                    try
                                    {
                                        info.SetValue(mg, int.Parse(strValue));
                                    }
                                    catch
                                    {
                                        info.SetValue(mg, 0);
                                    }
                                }
                                else if (t == typeof(double))
                                {
                                    try
                                    {
                                        info.SetValue(mg, double.Parse(strValue));
                                    }
                                    catch
                                    {
                                        info.SetValue(mg, 0);
                                    }
                                }
                                else if (t == typeof(DateTime))
                                {
                                    info.SetValue(mg, DateTime.Parse(strValue));
                                }
                                else
                                {
                                    info.SetValue(mg, strValue);
                                }
                            }
                            catch { }
                        }
                    }
                    mg.StartingPrice *= 10000;
                    mg.BidBond *= 10000;

                    mg.Save();
                    tr = tr.NextSibling;
                }
            }
            catch (Exception ex)
            {
                Program.MainForm.AddMessage("错误!宜兴地块数据抓取错误。链接:" + mg.SourceLink + "。地块Id:" + mg.GroundNum + "。错误消息:" + ex.Message);
            }

            this.NavToNext();
        }
Beispiel #7
0
        void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (e.Url != Document.Url) return;
            if (regUrl.IsMatch(e.Url.ToString()))
            {
                foreach (HtmlElement elLink in Document.GetElementsByTagName("a"))
                {
                    try
                    {
                        string strLink = elLink.GetAttribute("href");
                        if (regLink.IsMatch(strLink))
                        {
                            listLink.Add(new KeyValuePair<string, object>(strLink, elLink.InnerText));
                        }
                    }
                    catch { }
                }

                try
                {
                    HtmlElement btnNext = Document.Body.Children[2].GetElementsByTagName("input")[2];
                    if (bool.Parse(btnNext.GetAttribute("disabled"))) this.NavToNext();
                    else
                    {
                        page++;
                        this.Navigate("http://gtj.wuxi.gov.cn/BA13/D/04/index_" + page.ToString() + ".shtml");
                    }
                }
                catch { this.NavToNext(); }
                return;
            }

            Model_Ground mg = new Model_Ground("无锡");

            //开始计算信息包括的字段
            List<string> arrCol = new List<string>();
            HtmlElement tRow = null;
            HtmlElement tRowSub = null;
            try
            {
                int subIndex = 0;
                foreach (HtmlElement td in Document.GetElementById("Zoom").GetElementsByTagName("td"))
                {
                    try
                    {
                        string str = td.InnerText.Replace("\n","").Replace("\r","").Replace(" ","").Replace(" ","").Trim();
                        if (str == "编号" || str == "地块编号")
                        {
                            tRow = td.Parent;
                            if (int.Parse(td.GetAttribute("rowspan")) > 1) tRowSub = tRow.NextSibling;
                            break;
                        }
                    }
                    catch { }
                }

                foreach (HtmlElement td in tRow.Children)
                {
                    string str = td.InnerText.Replace("\n","").Replace("\r","").Replace(" ","").Replace(" ","").Trim();
                    str = regColNameFilter.Replace(str, "");
                    KeyValuePair<string, string> kvCol;
                    try
                    {
                        kvCol = listColName.FindAll(delegate(KeyValuePair<string, string> kv) { return kv.Key == str; })[0];
                        arrCol.Add(kvCol.Value);
                    }
                    catch
                    {
                        if (!arrPlaning.Contains(str))
                        {
                            arrCol.Add("");
                            continue;
                        }
                    }

                    int colSpan = int.Parse(td.GetAttribute("colspan"));
                    if (colSpan == 1||int.Parse(td.GetAttribute("rowspan"))>1) continue;
                    for (int i = 0; i < colSpan; i++)
                    {
                        str = tRowSub.Children[i + subIndex].InnerText.Replace("\n", "").Replace("\r", "").Replace(" ", "").Replace(" ", "").Trim();
                        str = regColNameFilter.Replace(str, "");
                        try
                        {
                            kvCol = listColName.FindAll(delegate(KeyValuePair<string, string> kv) { return kv.Key == str; })[0];
                            arrCol.Add(kvCol.Value);
                        }
                        catch
                        {
                            arrCol.Add("");
                            continue;
                        }
                    }
                }
            }
            catch { this.NavToNext(); return; }
            //mg.SourceLink = linkCurrent.Key;
            mg.SourceLink = linkCurrent.Key;

            //开始计算挂牌日期
            foreach (HtmlElement td in Document.GetElementsByTagName("td"))
            {
                if (td.InnerText!=null&&td.InnerText.Trim() == "公开日期")
                {
                    try
                    {
                        mg.ListingDate = DateTime.Parse(td.NextSibling.InnerText);
                    }
                    catch { }
                    break;
                }
            }

            //开始计算挂牌编号
            Match mListingNum = regListingNum.Match(Document.Title);
            if (mListingNum.Success)
            {
                mg.ListingNum = mListingNum.Value;
            }

            //开始计算每条招拍挂信息
            int[] arrRowSpan = new int[arrCol.Count];
            try
            {
                Type type = typeof(Model_Ground);
                HtmlElement tr = (tRowSub == null ? tRow : tRowSub).NextSibling;
                while (tr!=null)
                {
                    if (tr.Children.Count == 0) break;
                    string strGroundNum = tr.Children[0].InnerText;
                    if (strGroundNum == null) break;
                    strGroundNum = strGroundNum.Replace("\r", "").Replace("\n", "").Replace(" ","").Replace(" ","").Trim();
                    Match mGroundNum = regGroundNum.Match(strGroundNum);
                    if (!mGroundNum.Success)
                    {
                        tr = tr.NextSibling;
                        continue;
                    }
                    mg.GroundNum = mGroundNum.Value;

                    int offset = 0;

                    string strImageLink = null;
                    for (int i = 1; i < arrCol.Count; i++)
                    {
                        if (arrCol[i] == "" || arrCol[i] == null) continue;
                        if (arrRowSpan[i] > 0)
                        {
                            offset++;
                            arrRowSpan[i]--;
                            continue;
                        }

                        if (arrCol[i] == "GroundName")
                        {
                            try
                            {
                                strImageLink = tr.Children[i - offset].GetElementsByTagName("a")[0].GetAttribute("href");
                            }
                            catch { }
                        }

                        string strValue = tr.Children[i-offset].InnerText;
                        if (strValue != null)
                        {
                            strValue = strValue.Replace("\n", "").Replace("\r", "").Trim();
                        }
                        FieldInfo info = type.GetField(arrCol[i]);
                        Type t = info.FieldType;

                        int rowSpan = int.Parse(tr.Children[i-offset].GetAttribute("rowspan"))-1;
                        if (rowSpan > 0)
                        {
                            arrRowSpan[i] = rowSpan;
                        }
                        try
                        {
                            if (t == typeof(int))
                            {
                                info.SetValue(mg, int.Parse(strValue));
                            }
                            else if (t == typeof(double))
                            {
                                info.SetValue(mg, double.Parse(strValue));
                            }
                            else if (t == typeof(DateTime))
                            {
                                info.SetValue(mg, DateTime.Parse(strValue));
                            }
                            else
                            {
                                info.SetValue(mg, strValue);
                            }
                        }
                        catch { }
                    }
                    mg.GroundName = mg.GroundName.Split('.')[0];
                    mg.StartingPrice *= 10000;
                    mg.BidBond *= 10000;
                    mg.Save();

                    Model_Ground_File mgf = new Model_Ground_File(mg.CityId, mg.GroundNum);
                    if (strImageLink != null && strImageLink != ""&&mgf.GroundId>0)
                    {
                        try
                        {
                            string[] tmp = strImageLink.Split('/');
                            string strFileName = mg.CityId + "_" + tmp[tmp.Length - 1];
                            if (!Fn.IsExistGroundFile(strFileName, FileType.Image))
                            {
                                bool b = Fn.DownloadFile(strImageLink, strFileName, FileType.Image);
                                if (b)
                                {
                                    mgf.FileName = strFileName;
                                    mgf.FileTitle = "土地红线图";
                                    mgf.FileType = FileType.Image;
                                    mgf.Save();
                                }
                            }

                        }
                        catch { }
                    }
                    tr = tr.NextSibling;
                }
            }
            catch (Exception ex)
            {
                Program.MainForm.AddMessage("错误!无锡地块数据抓取错误。链接:" + mg.SourceLink + "。地块Id:" + mg.GroundNum + "。错误消息:" + ex.Message);
            }

            this.NavToNext();
            
        }
Beispiel #8
0
        void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (e.Url != Browser.Url) return;
            if (e.Url.ToString().StartsWith("http://www.ntgt.gov.cn/gtzygl/app/gpcrController/listGpcrBySx?"))
            {
                bool flag = false;
                foreach (HtmlElement el in Document.GetElementsByTagName("a"))
                {
                    try
                    {
                        string url = el.GetAttribute("href").Trim();
                        if (!url.StartsWith("http://www.ntgt.gov.cn/gtzygl/app/gpcrController/getView0/")) continue;
                        flag = true;
                        string strGrdNum = el.Parent.Parent.FirstChild.InnerText.Trim();
                        if (Fn.GetDT_PgSQL("select * from ground_info where cityid='" + cityId + "' and groundnum=" + q + strGrdNum + q + " and clinchprice>0").Rows.Count > 0) continue;
                        listLink.Add(new KeyValuePair<string, object>(url, strGrdNum));

                    }
                    catch { }

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

            try
            {
                HtmlElement div = null;
                foreach (HtmlElement el in Document.GetElementsByTagName("p"))
                {
                    if (el.InnerText == "基本情况")
                    {
                        div = el.NextSibling;
                        break;
                    }
                }

                Model_Ground mg = new Model_Ground("南通");
                mg.GroundNum = this.linkCurrent.Value.ToString();
                mg.SourceLink = this.linkCurrent.Key;

                bool flagSold = false;
                string strImageLink = null;
                foreach (HtmlElement p in div.Children)
                {
                    if (p.TagName.ToLower() != "p") continue;
                    string txt=null;
                    try { txt = p.InnerText.Trim(); }
                    catch { continue; }
                    int index = txt.IndexOf(":");
                    if (index < 0) index = txt.IndexOf(":");
                    if (index < 0) continue;
                    string name = txt.Substring(0, index);
                    string val = null;
                    try { val = txt.Substring(index + 1); }
                    catch { }

                    if (val == null || val.Trim() == "") continue;
                    val = val.Trim();
                    #region 计算上市字段值
                    try
                    {
                        switch (name)
                        {
                            case "地块座落":
                                mg.GLocation = val;
                                break;

                            case "用地性质":
                                mg.GUsage = val;
                                break;

                            case "地块面积":
                                mg.GArea = Convert.ToDouble(val.Replace("平方米", ""));
                                break;

                            case "起 挂 价":
                                mg.StartingPrice = Convert.ToDouble(val.Replace("元/平方米", "").Trim()) * mg.GArea;
                                break;

                            case "容 积 率":
                                mg.PlotRatio = val;
                                break;

                            case "建筑密度":
                                mg.BuildingDensity = val;
                                break;

                            case "绿 化 率":
                                mg.GreeningRate = val;
                                break;

                            case "开发程度":
                                mg.DevelopLevel = val;
                                break;

                            case "备  注":
                                mg.Remark = val;
                                break;

                            case "报价增幅":
                                mg.IncreaseRate = val;
                                break;

                            case "起始时间":
                                mg.ListingDate = Convert.ToDateTime(val);
                                break;

                            case "终止时间":
                                mg.ClinchDate = Convert.ToDateTime(val);
                                break;

                            case "挂牌情况":
                                if (val == "成交") flagSold = true;
                                else mg.ClinchDate = Convert.ToDateTime("1900-01-01");
                                break;

                        }
                    }
                    catch { }
                    #endregion
                }

                try
                {
                    strImageLink = div.Parent.FirstChild.Children[1].GetAttribute("src");
                }
                catch { }

                if (flagSold)
                {
                    div = div.GetElementsByTagName("div")[0];
                    mg.Buyer = div.Children[0].InnerText.Split(':')[1].Trim();
                    mg.ClinchPrice = Convert.ToDouble(div.Children[1].InnerText.Split(':')[1].Replace("元/平方米", "")) * mg.GArea;
                    mg.Save(true, null);
                }
                else
                {

                    mg.Save();
                }

                Model_Ground_File mgf = new Model_Ground_File(mg.CityId, mg.GroundNum);
                if (strImageLink != null && strImageLink != "" && mgf.GroundId > 0)
                {
                    try
                    {
                        string strFileName = mg.CityId + "_ground_" + mg.GroundNum+".jpg";
                        if (!Fn.IsExistGroundFile(strFileName, FileType.Image))
                        {
                            bool b = Fn.DownloadFile(strImageLink, strFileName, FileType.Image);
                            if (b)
                            {
                                mgf.FileName = strFileName;
                                mgf.FileTitle = "土地位置图";
                                mgf.FileType = FileType.Image;
                                mgf.Save();
                            }
                        }

                    }
                    catch { }
                }

            }
            catch { }
            this.NavToNext();
        }
Beispiel #9
0
        void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (e.Url != Document.Url) return;
            if (e.Url.ToString() == "http://gtj.jiangyin.gov.cn/jygt/sitePages/channelPages/135034050062403.html")
            {
                this.timer1.Interval = 3000;
                this.timer1.Start();
                return;
            }

            Model_Ground mg = new Model_Ground("江阴");

            //开始计算信息包括的字段
            List<string> arrCol = new List<string>();
            HtmlElement tRow = null;
            HtmlElement tRowSub = null;
            try
            {
                int subIndex = 0;
                foreach (HtmlElement td in Document.GetElementById("lk_wcms_edit_pictext701content").GetElementsByTagName("td"))
                {
                    try
                    {
                        string str = td.InnerText.Replace("\n", "").Replace("\r", "").Replace(" ", "").Replace(" ", "").Trim();
                        if (str == "宗地编号" || str == "地块编号")
                        {
                            tRow = td.Parent;
                            if (int.Parse(td.GetAttribute("rowspan")) > 1) tRowSub = tRow.NextSibling;
                            break;
                        }
                    }
                    catch { }
                }

                foreach (HtmlElement td in tRow.Children)
                {
                    string str = td.InnerText.Replace("\n", "").Replace("\r", "").Replace(" ", "").Replace(" ", "").Trim();
                    str = regColNameFilter.Replace(str, "");
                    KeyValuePair<string, string> kvCol;
                    int colSpan = int.Parse(td.GetAttribute("colspan"));
                    try
                    {
                        kvCol = listColName.FindAll(delegate(KeyValuePair<string, string> kv) { return kv.Key == str; })[0];
                        arrCol.Add(kvCol.Value);
                    }
                    catch
                    {
                        if (colSpan==1)
                        {
                            arrCol.Add("");
                            continue;
                        }
                    }

                    if (colSpan == 1) continue;
                    for (int i = 0; i < colSpan; i++)
                    {
                        str = tRowSub.Children[i + subIndex].InnerText.Replace("\n", "").Replace("\r", "").Replace(" ", "").Replace(" ", "").Trim();
                        str = regColNameFilter.Replace(str, "");
                        try
                        {
                            kvCol = listColName.FindAll(delegate(KeyValuePair<string, string> kv) { return kv.Key == str; })[0];
                            arrCol.Add(kvCol.Value);
                        }
                        catch
                        {
                            arrCol.Add("");
                            continue;
                        }
                    }
                }
            }
            catch { this.NavToNext(); return; }
            //mg.SourceLink = linkCurrent.Key;
            mg.SourceLink = Document.Url.ToString().Replace(".html",".jsp");

            string strContent = Document.GetElementById("lk_wcms_edit_pictext701content").InnerText;
            if (strContent == null) strContent = "";
            //开始计算挂牌日期
            Match mListingDate = regListingDate.Match(strContent);
            if (mListingDate.Success)
            {
                string strYear = ReplaceChineseToNum(mListingDate.Groups[1].Value);
                string strMonth = ReplaceChineseToNum(mListingDate.Groups[2].Value);
                string strDay = ReplaceChineseToNum(mListingDate.Groups[3].Value);
                try
                {
                    mg.ListingDate = DateTime.Parse(strYear + "-" + strMonth + "-" + strDay);
                }
                catch { }
            }

            //开始计算挂牌编号
            Match mListingNum = regListingNum.Match(strContent);
            if (mListingNum.Success)
            {
                mg.ListingNum = mListingNum.Value;
            }

            //开始计算每条招拍挂信息
            try
            {
                Type type = typeof(Model_Ground);
                HtmlElement tr = (tRowSub == null ? tRow : tRowSub).NextSibling;
                while (tr != null)
                {
                    for (int i = 0; i < arrCol.Count; i++)
                    {
                        if (arrCol[i] == "" || arrCol[i] == null) continue;

                        string strValue = "";
                        try
                        {
                            strValue = tr.Children[i].InnerText;
                        }
                        catch { }
                        if (strValue != null)
                        {
                            strValue = strValue.Replace("\n", "").Replace("\r", "").Replace(" ", "").Replace(" ", "").Trim();
                        }
                        FieldInfo info = type.GetField(arrCol[i]);
                        Type t = info.FieldType;

                        try
                        {
                            if (t == typeof(int))
                            {
                                try
                                {
                                    info.SetValue(mg, int.Parse(strValue));
                                }
                                catch
                                {
                                    info.SetValue(mg, 0);
                                }
                            }
                            else if (t == typeof(double))
                            {
                                try
                                {
                                    info.SetValue(mg, double.Parse(strValue));
                                }
                                catch
                                {
                                    info.SetValue(mg, 0);
                                }
                            }
                            else if (t == typeof(DateTime))
                            {
                                info.SetValue(mg, DateTime.Parse(strValue));
                            }
                            else
                            {
                                info.SetValue(mg, strValue);
                            }
                        }
                        catch { }
                    }
                    mg.GroundNum = mg.GroundNum.Replace("澄地", "").Trim();
                    mg.StartingPrice *= 10000;
                    mg.BidBond *= 10000;
                    mg.InvestmentIntensity = mg.InvestmentIntensity / mg.GArea / 0.0015;

                    mg.Save();
                    tr = tr.NextSibling;
                }
            }
            catch (Exception ex)
            {
                Program.MainForm.AddMessage("错误!江阴地块数据抓取错误。链接:" + mg.SourceLink + "。地块Id:" + mg.GroundNum + "。错误消息:" + ex.Message);
            }

            this.NavToNext();
        }
Beispiel #10
0
 private void GetLinks()
 {
     Model_Ground mg = new Model_Ground("江阴");
     try
     {
         HtmlElement tbody = Document.GetElementById("linkTable").Children[0];
         foreach (HtmlElement elLink in tbody.GetElementsByTagName("a"))
         {
             try
             {
                 string strLink = elLink.GetAttribute("href");
                 if (regLink.IsMatch(strLink)&&!mg.IsExistLink(strLink))
                 {
                     listLink.Add(new KeyValuePair<string, object>(strLink, null));
                 }
             }
             catch { }
         }
     }
     catch(Exception ex) {
         Program.MainForm.AddMessage("错误!抓取江阴挂牌土地链接时出错。链接:"+Document.Url.ToString() +",第"+ pageCurrent + "页。错误消息:"+ ex.Message);
     }
 }