static void Main() { SimpleCrawler myCrawler = new SimpleCrawler(); string startUrl = "http://www.cnblogs.com/dstang2000/"; if (args.Length >= 1) { startUrl = args[0]; } myCrawler.urls.Add(startUrl, false);//加入初始页面 new Thread(myCrawler.Crawl).Start(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); }
private void BtnCrawl_Click(object sender, EventArgs e) { if (!Regex.IsMatch(txtUrl.Text, @"http[s]?://")) { MessageBox.Show("输入的地址格式不正确,请重新输入!"); } else { SimpleCrawler crawler = new SimpleCrawler(txtUrl.Text); crawler.startCrawl(); detailBindingSource.DataSource = crawler; for (int i = 0; i < 100; i++) { detailBindingSource.ResetBindings(false); Thread.Sleep(50); } } }