private void MaterialRaisedButton2_Click(object sender, EventArgs e) { if (!String.IsNullOrWhiteSpace(NEW.Text)) { if (Base64C.IsValidUri(NEW.Text)) { if (Base64C.CheckReachableSite(NEW.Text)) { WebClient x = new WebClient(); string source = x.DownloadString($"{NEW.Text}"); string title = Regex.Match(source, @"\<title\b[^>]*\>\s*(?<Title>[\s\S]*?)\</title\>", RegexOptions.IgnoreCase).Groups["Title"].Value; Site site = new Site(title, NEW.Text); site.Show(); } else { SystemSounds.Beep.Play(); MessageBox.Show("Site does not exist!"); } } else { SystemSounds.Beep.Play(); MessageBox.Show("That is not a valid url!"); } } }
private void GetTitle_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex != -1) { if (Base64C.IsValidUri(listBox1.SelectedItem.ToString())) { WebClient x = new WebClient(); string source = x.DownloadString(listBox1.SelectedItem.ToString()); string title = Regex.Match(source, @"\<title\b[^>]*\>\s*(?<Title>[\s\S]*?)\</title\>", RegexOptions.IgnoreCase).Groups["Title"].Value; MessageBox.Show(title); } else { SystemSounds.Beep.Play(); MessageBox.Show("That is not a valid url!"); } } }