private void ribbonTabItemNCT_Click(object sender, EventArgs e) { if (cboNCT_TheLoai.Items.Count <= 0) { _CurrentPage = "1"; List <clsLinkA> linkAs = new List <clsLinkA>(); _CateogryLink = new List <clsLinkA>(); _ArtistLink = new List <clsLinkA>(); _pages = new List <clsLinkA>(); linkAs = clsSearch.Category("http://v6.nhaccuatui.com"); cboNCT_TheLoai.Items.Clear(); cboNCT_CaSi.Items.Clear(); for (int i = 0; i < linkAs.Count; i++) { _CateogryLink.Add(linkAs[i]); cboNCT_TheLoai.Items.Add(linkAs[i].StrName); } cboNCT_CaSi.Items.AddRange(new string[] { "Tên bài hát/ chủ đề", "Tên ca sĩ/ trình diễn" }); clsLinkA link = new clsLinkA(); link.StrName = "Tên bài hát/ chủ đề"; link.StrHref = ""; _ArtistLink.Add(link); link = new clsLinkA(); link.StrName = "Tên ca sĩ/ trình diễn"; link.StrHref = "casi"; _ArtistLink.Add(link); if (cboNCT_TheLoai.Items.Count > 0) { cboNCT_TheLoai.SelectedIndex = 0; } if (cboNCT_CaSi.Items.Count > 0) { cboNCT_CaSi.SelectedIndex = 0; } } }
public static List <clsLinkA> Category(object linkBegin) { List <string> category = new List <string>(); List <clsLinkA> LinkA = new List <clsLinkA>(); string link = (string)linkBegin; string data = clsHTML.GetHTML(link); string Beginsplit = string.Empty; string Endsplit = string.Empty; string RegexPattern = "<.*a.*?href=.*?\"(?<GroupId>.*?)\".*?>(?<GroupName>.*?)<.*/.*a.*>"; if (link.Contains("nhaccuatui.com")) { Beginsplit = "category-box"; Endsplit = "menu-hot-keyword"; } else { Beginsplit = "THỂ LOẠI"; Endsplit = "maincol"; } category.AddRange(data.Split(new string[] { Beginsplit, Endsplit }, StringSplitOptions.RemoveEmptyEntries)); category.RemoveAt(0); category.RemoveAt(1); MatchCollection matchs = Regex.Matches(category[0], RegexPattern, RegexOptions.IgnoreCase); category.Clear(); foreach (Match match in matchs) { clsLinkA a = new clsLinkA(); a.StrName = match.Groups["GroupName"].Value; a.StrHref = match.Groups["GroupId"].Value; LinkA.Add(a); } return(LinkA); }
private void SearchPage(string data, string begin, string end, string Site) { if (data.Contains(begin)) { _MainForm._pages.Clear(); string tempPage = data.Substring(data.IndexOf(begin)); tempPage = tempPage.Remove(tempPage.IndexOf(end)); string[] pages = tempPage.Split(new string[] { begin, end }, StringSplitOptions.RemoveEmptyEntries); string regexPatternPage = @"<a.*?href=[""'](?<GroupId>.*?)[""'].*?((title=[""'](?<GroupTitle>.*?)[""'])|)>.*?(?<GroupName>.*?)</a>"; MatchCollection matchPage = null; if (pages.Length > 1) { matchPage = Regex.Matches(pages[1], regexPatternPage, RegexOptions.IgnoreCase); } else { matchPage = Regex.Matches(pages[0], regexPatternPage, RegexOptions.IgnoreCase); } foreach (Match page in matchPage) { clsLinkA linkPage = new clsLinkA(); if (page.Groups["GroupName"].Success && page.Groups["GroupId"].Success) { linkPage.StrName = page.Groups["GroupName"].Value.Trim(); if (Site.Contains("nhaccuatui")) { linkPage.StrHref = "http://v6.nhaccuatui.com" + page.Groups["GroupId"].Value; } else { linkPage.StrHref = page.Groups["GroupId"].Value; } _MainForm._pages.Add(linkPage); } } if (_MainForm._pages.Count > 0) { int temp = int.Parse(_MainForm._pages[_MainForm._pages.Count - 1].StrName.Trim()); int indexPage = 0; for (int i = temp - _MainForm._pages.Count; i <= temp; i++) { foreach (clsLinkA item in _MainForm._pages) { if (i.ToString() != item.StrName.Trim()) { _MainForm._CurrentPage = i.ToString(); clsLinkA linkpage = new clsLinkA(); linkpage.StrName = i.ToString(); if (Site.Contains("nhaccuatui")) { linkpage.StrHref = _MainForm._pages[0].StrHref.Replace(_MainForm._pages[0].StrName, _MainForm._CurrentPage.ToString()); _MainForm._pages.Insert(indexPage, linkpage); _MainForm.Invoke(new MusicOnline.MainForm.delegateUpdatePage(_MainForm.UpdatePage), new object[] { "http://v6.nhaccuatui.com" }); return; } else { linkpage.StrHref = _MainForm._pages[0].StrHref.Replace(_MainForm._pages[0].StrName + ".html", _MainForm._CurrentPage.ToString() + ".html"); _MainForm._pages.Insert(indexPage, linkpage); _MainForm.Invoke(new MusicOnline.MainForm.delegateUpdatePage(_MainForm.UpdatePage), new object[] { "http://mp3.zing.vn" }); return; } } i++; indexPage++; } } } } }