//mshtml.HTMLDocument mhtml = (mshtml.HTMLDocument)Webbrowser2.Document; //string html = mhtml.body.innerHTML; //IHtmlDocument document = new JumonyParser().Parse(html); //IEnumerable<IHtmlElement> result = document.Find("div").Where(i => i.Identity() == "all-list"); //result = result.Find("li"); // foreach (var li in result) // { // Class1 _class = new Class1(); //_class.TextName = GetN_value(li, ".media-body-title>a"); //_class.href = li.FindFirst(".media-body-title>a").Attribute("href").Value(); //_class.Quyu = "百姓"; // _class.Laiyuan = "百姓"; // _class.Address = GetN_value(li, ".typo-small"); //string this_spk = GetN_value(li, ".typo-small"); //_class.SumMoney = GetN_value(li, ".highlight"); //string[] thip = this_spk.Split('/'); //_class.PingMoney = thip.Length>1? thip[1]:""; // _class.Allpm = ""; // _class.datetime = GetN_value(li, ".pull-right"); // if (li.Exists("img")) // { // if (li.FindFirst("img").Attribute("src").Value().IndexOf("http") < 0) // { // _class.Image_str = string.Empty; // } // else // { // _class.Image_str = "有"; // } // } // else if (li.Exists(".img")) // { // if (li.FindFirst(".img").Attribute("src").Value().IndexOf("http") < 0) // { // _class.Image_str = string.Empty; // } // else // { // _class.Image_str = "有"; // } // } // else // { // _class.Image_str = string.Empty; // } // L_Class.Add(_class); // } #endregion #endregion #region 读取网站区域 private void GetSelectQuYu(IHtmlDocument document) { IEnumerable <IHtmlElement> result = document.Find("div").Where(i => i.Identity() == "qySelectFirst").Find("a"); List <URL_list> llt = new List <URL_list>(); foreach (var rt in result) { Quyu urt = new Quyu(); urt.ID = Id; urt.Name = rt.InnerText(); urt.Href = rt.Attribute("href").Value(); Quyulist_58.Add(urt); } }
private void newvoid() { L_Class.Clear(); DataGrid.ItemsSource = null; r = 0; this.Dispatcher.Invoke(new Action(() => { page_text.Text = "当前第" + page + "页"; Page_text.Text = page.ToString(); })); #region 网址重组加载数据 //-----------------------------赶集网开始读取-----------------------------------------// URL = URL_List_[1].Href; Id = URL_List_[1].ID; URL = page == 1 ? URL : URL + "o" + page.ToString() + "/"; //对感觉进行抓取 WebClient client = new WebClient(); client.Encoding = Encoding.UTF8; string html = client.DownloadString(URL); IHtmlDocument document = new JumonyParser().Parse(html); //首次进入 读取区域数据 if (fristLoad_1) { #region MyRegion IEnumerable <IHtmlElement> result = document.Find(".warpper").Where(c => c.Attribute("data-key").Value() == "street"); result = result.Find("a"); foreach (var fh in result) { Quyu qy = new Quyu(); qy.Href = fh.Attribute("href").Value(); qy.Name = fh.InnerText().Replace("全", ""); qy.ID = Id; Quyulist_ganji.Add(qy); } fristLoad_1 = false; #endregion } GetUrlText_2(document, L_Class); //-----------------------------赶集网读取结束-----------------------------------------// //-------------------------------读取58开始---------------------------------// URL = URL_List_[0].Href; Id = URL_List_[0].ID; URL = page == 1 ? URL : URL + "/pn" + page.ToString() + "/"; //58网站对区域进行搜索进行二次修改网站地址 if (!fristLoad) { string name = ((newWORD.Quyu)CB_qy.SelectedValue).Href; name = name.Remove(name.IndexOf("/0")); URL = URL.Replace("/ershoufang", name); } //对58进行加载 GO_58com_new(); //-------------------------------读取58结束---------------------------------// //URL = URL_List_[2].Href; //Id = URL_List_[2].ID; //URL = page == 1 ? URL : URL + "&page=" + page.ToString() ; //Webbrowser2.Navigate(URL); //-------------------------------读取安居客开始---------------------------------// URL = URL_List_[3].Href; Id = URL_List_[3].ID; URL = page == 1 ? URL : URL + "&page=" + page.ToString(); Webbrowser2.Navigate(URL); //-------------------------------读取安居客结束---------------------------------// #endregion //往前台赋值 this.Dispatcher.Invoke(new Action(() => { })); Dtimer.Stop(); this.Dispatcher.Invoke(new Action(() => { lobr.Visibility = Visibility.Hidden; lobr_text.Visibility = Visibility.Hidden; })); }