Xamarin: How to get HTML from page in WebView?

12,363

You can just use javascript webView.EvaluateJavascript ("document.body.innerHTML")

Share:
12,363
lp6m
Author by

lp6m

Updated on June 11, 2022

Comments

  • lp6m
    lp6m about 2 years

    Xamarin: How to get HTML from page in WebView?

    I develop Xamarin App for iOS and I am using WebView.

    Just to get HTML of page, I use the following code.

    WebClient wc = new WebClient();
    using (Stream st = wc.OpenRead("http://study-csharp.blogspot.jp/")){
        using (StreamReader sr = new StreamReader(st, Encoding.UTF8)){
            string html = sr.ReadToEnd();
            Console.Write(html);
        }
    }
    

    However, I want HTML data after the user has logged in to the site in the webview.

    I can't find the method to get HTML in UIWebView.

    Thanks in advance.

  • lp6m
    lp6m about 9 years
    This work perfectly! Thanks!!
  • SANDEEP
    SANDEEP over 7 years
    is tihs working for Xamarin Fomrs..
  • Artur Shamsutdinov
    Artur Shamsutdinov over 7 years
  • Wizard
    Wizard over 4 years
    and how to get HTML string in C# code?
  • Rodney Willis
    Rodney Willis almost 4 years
    This answer doesn't work anymore in Xamarin Forms 4.6+