private void PositionSelector_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { try { if (!SearchQueryInput.Text.Equals(string.Empty)) { coList.Clear(); ResultListView.Items.Clear(); string result = Network.Request("https://work.mma.go.kr/caisBYIS/search/byjjecgeomsaek.do?eopjong_gbcd=" + (PositionSelector.SelectedIndex + 1) + "&eopche_nm=" + SearchQueryInput.Text); Document doc = NSoup.Parse.Parser.Parse(result, "https://work.mma.go.kr"); Elements elms = doc.Select("th.title.t-alignLt.pl20px"); foreach (var item in elms) { CoData coData = new CoData(); coData.SetName(item.Text()); coData.SetId(GetMiddleString(item.Select("a").Attr("href"), "byjjeopche_cd=", "&")); coList.Add(coData); ResultListView.Items.Add(coData.GetName() + Environment.NewLine + "기업코드: " + coData.GetId()); } } } catch { } }
private void SearchQueryInput_KeyUp(object sender, KeyEventArgs e) { if (!SearchQueryInput.Text.Equals(string.Empty) && e.Key.Equals(Key.Enter)) { coList.Clear(); ResultListView.Items.Clear(); string result = Network.Request("https://work.mma.go.kr/caisBYIS/search/byjjecgeomsaek.do?eopjong_gbcd=" + (PositionSelector.SelectedIndex + 1) + "&eopche_nm=" + SearchQueryInput.Text); Document doc = NSoup.Parse.Parser.Parse(result, "https://work.mma.go.kr"); Elements elms = doc.Select("th.title.t-alignLt.pl20px"); if (elms.Count.Equals(0)) { ResultListView.Items.Add("조회된 기업 없음"); LoadImageReady(); } foreach (var item in elms) { CoData coData = new CoData(); coData.SetName(item.Text()); coData.SetId(GetMiddleString(item.Select("a").Attr("href"), "byjjeopche_cd=", "&")); coList.Add(coData); ResultListView.Items.Add(coData.GetName() + Environment.NewLine + "기업코드: " + coData.GetId()); } } }