第一次运行需要超过 15 秒...第一次运行后需要不到 1 秒...我该如何解决?
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();
siteKeyword = tbSearch.Text;
web.OverrideEncoding = Encoding.GetEncoding("windows-1251");
doc = web.Load(siteSearch + siteKeyword);
HtmlNodeCollection items = doc.DocumentNode.SelectNodes("//div[@class='cls1']");
int i = 0;
foreach (var item in items)
{
lbResults.Items.Add(item.SelectSingleNode("h2/a").InnerText);
resultsHREF.Add(item.SelectSingleNode("h2/a").Attributes["href"].Value);
i++;
}
sw.Stop();
MessageBox.Show(sw.ElapsedMilliseconds.ToString("00:00:000"));
sw.Reset();