WebKitBrowser中有一種方法SelectedText
,但是,沒有SelectAll
。有沒有辦法爲我做類似如下:如何在Webkit.Net中選擇用戶控件WebKitBrowser的所有文本?
string GetAllTextOfBrowserAsPlainText(WebKitBrowser webKitBrowser)
{
webKitBrowser.SelectAll(); //Doesn't exist
return webKitBrowser.SelectedText;
}
我的目標是使網頁完全(包括造型),然後複製網頁的內容在平面的文字,如果我使用複製/粘貼在我的瀏覽器中。
獲取InnerText
或直接使用HTML不是一種選擇。
我試過WebBrowser UC WebBrowser1.Document.ExecCommand
捕捉文本,但我無法讓樣式正常工作。我現在正在嘗試WebKit,並且我非常接近我想要的。任何幫助? WebKit是否存在ExecCommand("SelectAll",...)
?
但是,謝謝您下載URL的HTML。我不是在尋找HTML,我希望顯示的內容爲純文本。如果你在你喜歡的網絡瀏覽器中進入一個網頁,然後按Ctrl + A和Ctrl + C,然後轉到記事本,然後按Ctrl + V,那麼記事本的內容就是我想要的字符串。也就是說,我希望應用樣式和任何腳本,然後獲取網頁顯示內容的平面文本。 –
考慮使用像htmlagilitypack這樣的東西,從HTML單獨獲取文本部分 –
http://htmlagilitypack.codeplex.com/sourcecontrol/changeset/view/62772#52179 –