搞搞异步,采集下博客园新闻的第一页。
public async static void DoRun()
{
Stopwatch watch = new Stopwatch();
watch.Start();
HttpClient httpClient = new HttpClient();
string url = "https://news.cnblogs.com/";
Search search = new Search();
List<Article> articles = new List<Article>();
HtmlDocument doc = new HtmlDocument();
var list = search.CrawlerCnblosNewsList(url, httpClient, doc);
List<Task> taskList = new List<Task>();
foreach (var item in list)
{
taskList.Add(search.CrawlerCnblosNews4(item, articles, httpClient, doc));
}
await Task.WhenAll(taskList.ToArray());
//foreach (var article in articles)
//{
// Console.WriteLine(article.ID);
// Console