private void button1_Click(object sender, EventArgs e) { IArchiveService service = new WebArchiveService(); this.SearchResult = service.Load(this.textBox1.Text); webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted); if (this.SearchResult.ArchiveWebsites.Count > 0) { this.ShowNextWebsite(0); } }
public Website GetWebsite(string url) { string archiveUrl = "http://web.archive.org/web/*/" + url; HttpWebRequest rq = (HttpWebRequest)WebRequest.Create(archiveUrl); HttpWebResponse response = (HttpWebResponse)rq.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream()); string html = reader.ReadToEnd(); Website resultWebsite = new Website(); resultWebsite.Url = url; MatchCollection matchs = Regex.Matches(html, @"<a.href=.http://web.archive.org/web/\d.*?</a>"); foreach (Match match in matchs) { ArchiveWebsite archive = new ArchiveWebsite(); archive.ArchiveUrl = Regex.Match(match.Value, @"http://web.archive.org/web/\d*").Value + "/" + url; archive.Date = DateTime.Parse(Regex.Match(match.Value, @"\w\w\w\s\d\d,\s\d\d\d\d").Value); resultWebsite.ArchiveWebsites.Add(archive); } return resultWebsite; }