folks. I want to crawl data from a few pages with webview2. I am about to load and extract data from the pages one by one. I wrote some codes but they didn't work. I am stuck. Here are the core codes:
async Task Crawl()
{
AutoResetEvent loadEvent = new AutoResetEvent(false);
wv2.NavigationCompleted += Wv2_NavigationCompleted;
foreach (var url in urls)
{
wv2.Source = new Uri(url);
loadEvent.WaitOne();
var data = await ExtractData();
...
}
wv2.NavigationCompleted -= Wv2_NavigationCompleted;
void Wv2_NavigationCompleted(object sender, CoreWebView2NavigationCompletedEventArgs e)
{
loadEvent.Set();
}
}