webview2抓取返回数据
webview2设置过滤器
//进行网址过滤
//webView.CoreWebView2.AddWebResourceRequestedFilter("http://test.com:8080/xx", CoreWebView2WebResourceContext.All);
webView.CoreWebView2.WebResourceResponseReceived += CoreWebView2_WebResourceResponseReceivedAsync;
解析返回值
private async void CoreWebView2_WebResourceResponseReceivedAsync(object sender, CoreWebView2WebResourceResponseReceivedEventArgs e)
{
if (e.Response != null && e.Response.StatusCode == 200)
{
if (e.Request.Uri.Contains("/test/gettest"))
{
Stream content = await e.Response.GetContentAsync();
StreamReader sr = new StreamReader(content, System.Text.Encoding.UTF8);
string jsonText = sr.ReadToEnd();
}
}
}
留待后查,同时方便他人
联系我:renhanlinbsl@163.com
联系我:renhanlinbsl@163.com