void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { if (e.Url != Document.Url) return; if (e.Url.ToString().StartsWith("http://newhouse.njhouse.com.cn/detail.php?id=")) { try { this.Navigate(Document.GetElementsByTagName("iframe")[3].GetAttribute("src")); } catch { this.NavToNext(); } } else { try { List<object> arrInfo = linkCurrent.Value as List<object>; Model_EstateSold mes = new Model_EstateSold(int.Parse(arrInfo[0].ToString())); try { mes.SoldDateStart = DateTime.Parse(arrInfo[4].ToString()).AddDays(1); } catch { mes.SoldDateStart = new DateTime(1900, 1, 1); } mes.SoldDateEnd = DateTime.Today; int countAll = 0, countNew = 0; double areaAll = 0, areaNew = 0; double tPrice = 0, tPriceNew = 0; try { countAll = int.Parse(arrInfo[1].ToString()); } catch { } try { areaAll = double.Parse(arrInfo[2].ToString()); } catch { } try { tPrice = double.Parse(arrInfo[3].ToString()); } catch { } HtmlElement tbody = Document.Window.Frames[0].Document.GetElementsByTagName("table")[1].Children[0]; try { countNew = int.Parse(tbody.Children[2].Children[1].InnerText.Replace("套", "")); } catch { } try { areaNew = double.Parse(tbody.Children[2].Children[3].InnerText.Replace("m2", "")); } catch { } try { tPriceNew = double.Parse(tbody.Children[3].Children[1].InnerText.Replace("元/m2", "")); } catch { } tPriceNew *= areaNew; mes.SoldCount = countNew - countAll; mes.SoldArea = areaNew - areaAll; mes.avePrice = (tPriceNew - tPrice) / (areaNew - (tPrice == 0 ? 0 : areaAll)); mes.Save(false); if (tPrice == 0 && mes.avePrice != 0) Fn.ExecNonQuery_PgSQL("update estate_sold set aveprice=" + mes.avePrice + " where estid=" + mes.EstId + " and aveprice=0"); } catch { } this.NavToNext(); } }
void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { string url = e.Url.ToString(); if (url == "http://58.215.18.133:82/LandPriceWX/login.aspx") { Document.GetElementById("txtusername").SetAttribute("value", "PGJG"); Document.GetElementById("txtpassword").SetAttribute("value", "123456"); Document.GetElementById("Submit1").InvokeMember("click"); return; } if (url == "http://58.215.18.133:82/LandPriceWX/index_main.aspx") { this.Navigate("http://58.215.18.133:82/LandPriceWX/mapmain.aspx?ss=0,0,0,1"); return; } if (url == "http://58.215.18.133:82/LandPriceWX/mapquery.aspx?ss=0,0,0,1") { HtmlDocument doc = Document.Window.Frames[1].Document; HtmlElement tb = doc.GetElementById("table4").Children[0]; tb.Children[tb.Children.Count - 1].Children[0].Children[0].InvokeMember("click"); this.flagSearch = true; return; } if (flagSearch && url.StartsWith("http://58.215.18.133:82/LandPriceWX/mapresult_lp1.aspx")) { HtmlDocument doc = Document.Window.Frames[2].Document; foreach (HtmlElement el in doc.GetElementsByTagName("a")) { if (el.InnerText!=null&&el.InnerText.Trim()=="详细") { listLink.Add(new KeyValuePair<string, object>(el.GetAttribute("href"), null)); } } this.NavToNext(); return; } if (url.StartsWith("http://58.215.18.133:82/LandPriceWX/lp_zpg_edit.aspx?mode=show&id=")) { try { string strEstName = Document.GetElementById("LP_MC").GetAttribute("value"); HtmlElement tbPermit = Document.GetElementById("dg_xk").Children[0]; string strPermitId = tbPermit.Children[1].Children[1].InnerText.Trim(); string strPermitId1 = strPermitId; if (strPermitId.IndexOf("(") >= 0) { strPermitId1 = strPermitId.Replace("(", "(").Replace(")", ")"); } else if (strPermitId.IndexOf("(") >= 0) { strPermitId1 = strPermitId.Replace("(", "(").Replace(")", ")"); } int cityId = Fn.GetCityIdByName("无锡"); DataTable dt = Fn.GetDT_MySQL("select estnum from permitinfo where (permitnum='"+strPermitId+"' or permitnum='"+strPermitId1+"') and cityid="+cityId); string strEstNum = null; if (dt.Rows.Count > 1) { foreach (DataRow dr in dt.Rows) { try { string tmp = Fn.GetObj_PgSQL("select estname from estate_info where cityid=" + cityId + " and estnum='" + dr[0].ToString() + "'").ToString(); if (strEstName.IndexOf(tmp) >= 0 || tmp.IndexOf(strEstName) >= 0) { strEstNum = dr[0].ToString(); break; } } catch { } } } else strEstNum = dt.Rows[0][0].ToString(); int estId = int.Parse(Fn.GetObj_PgSQL("select id from estate_info where cityid="+cityId+" and estnum='"+strEstNum+"'").ToString()); HtmlElement tbXS = Document.GetElementById("dg_xs").Children[0]; Model_EstateSold mes = new Model_EstateSold(estId); for (int i = 1; i < tbXS.Children.Count; i++) { HtmlElement row = tbXS.Children[i]; string strTime = row.Children[1].InnerText; Match m = regTimeSpan.Match(strTime); int year = int.Parse(m.Groups[1].Value); int season = int.Parse(m.Groups[2].Value); mes.SoldDateStart = new DateTime(year, (season - 1) * 3 + 1, 1); mes.SoldDateEnd = new DateTime(year, season * 3, DateTime.DaysInMonth(year, season * 3)); mes.EstUsage = row.Children[2].InnerText; mes.SoldCount = int.Parse(row.Children[3].InnerText); mes.SoldArea = double.Parse(row.Children[4].InnerText); mes.avePrice = double.Parse(row.Children[6].InnerText); mes.Save(true); } HtmlElement next = null; foreach (HtmlElement el in Document.GetElementById("Pager2").GetElementsByTagName("a")) { if (el.InnerText == "下一页" && el.GetAttribute("href") != null&&el.GetAttribute("href")!="") { next = el; break; } } if (next != null) next.InvokeMember("click"); else this.NavToNext(); } catch { this.NavToNext(); } } }