如何与QUOT;呈现" HTML没有WebBrowser控件控件、QUOT、HTML、WebBrowser

2023-09-06 17:44:34 作者:带着梦想出发

首先,在所有 - 我不知道,如果渲染是正确的字。我喜欢从网站上获取信息。目前,所以我用WebBbrowser控制。 现在,我喜欢用HttpWebRequests,因为我认为,这是速度更快,线程可以更方便地使用。但我不能使用它们,因为我从HttpWebRequest的接收HTML的输出字符串已经得到了大量的JavaScript内从该信息,即我需要的,将被创建。 Web浏览器渲染的JavaScript以可读的HTML。如何做到这一步手动,这样我就可以使用HttpWebRequests?

First at all - I don't know if "render" is the right word. I like to get information from an website. At the moment therefore I use the WebBbrowser control. Now I like to use HttpWebRequests because I think, that's much faster and threading could be used more easily. But I can't use them, because the HTML-output string I receive from HttpWebRequest has got a lot of JavaScript inside from which the information, that I need, will be created. The web browser "renders" the JavaScript to readable HTML. How to do this step "by hand", so that I can use HttpWebRequests?

我希望你明白,我想要什么。

I hope you understand, what I want.

推荐答案

我解决我的问题与项目名为 Awesomium 。在此线程你会发现所有你需要得到的HTML与JavaScript的执行。 特殊的一部分是这个:

I solved my problem with a project called Awesomium. In this thread you will find all you need to get html with executed javascript. The "special part" is this one:

var sourceVal = webView.ExecuteJavascriptWithResult( "document.getElementsByTagName('html')[0].outerHTML;" );

if ( sourceVal != null )
{
    using ( sourceVal )
    {
        html = sourceVal.ToString();
    }
}