Is there a way to force NHTMLUNIT to Ignore Page JavaScript errors and Continue Script Execution?

后端 未结 1 1470
广开言路
广开言路 2021-02-08 02:47

I am part of ASP.NET and C# project. We are trying to make our asp.net portal Google search engine friendly (https://developers.google.com/webmasters/ajax-crawling/). Web pages

相关标签:
1条回答
  • 2021-02-08 03:22
    // Create a webclient.
    WebClient webClient = new WebClient(BrowserVersion.FIREFOX_17)
        {
            JavaScriptEnabled = true
            ThrowExceptionOnScriptError = false,
            ThrowExceptionOnFailingStatusCode = false,
        };
    
    webClient.WaitForBackgroundJavaScript(5000);
    
    HtmlPage htmlPage = webClient.GetHtmlPage(url);
    
    // Return the page for the given URL as Text.
    return htmlPage.WebResponse.ContentAsString;
    

    I noticed you didn't enable JavaScript, sorry if I'm wrong.

    0 讨论(0)
提交回复
热议问题