none
Get HTML from WebBrowser without opening RRS feed

  • Question

  • Hi, I have a problem. I want to get HTML of website but i can't use web client. I have an idea.. Create a new class and webbrowser inside and then use webbrowser1.document to get html but i have to open the window with class.. but i want to do this operation without opening. Is it  a possibility to do that? When I cause method which enable mi to get html od document i get an empty document because the website isn't upload.

    Please help!

    Wednesday, November 6, 2019 9:26 PM

All replies

  • Hi, I have a problem. I want to get HTML of website but i can't use web client. I have an idea.. Create a new class and webbrowser inside and then use webbrowser1.document to get html but i have to open the window with class.. but i want to do this operation without opening. Is it  a possibility to do that? When I cause method which enable mi to get html od document i get an empty document because the website isn't upload.

    Please help!

    Wednesday, November 6, 2019 9:25 PM
  • Hi PKasia,

    Thank you for posting here.

    According to your description, you can use the following code to get the HTML of the website.

                var uri = new System.Uri("your url of website");
                using (var httpClient = new HttpClient())
                {
                    try
                    {
                        string result = await httpClient.GetStringAsync(uri);
                    }
                    catch (Exception ex)
                    {
                        // Details in ex.Message and ex.HResult.
                    }
                }

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.



    Thursday, November 7, 2019 2:25 AM
    Moderator
  • In order to get the initial HTML, try this example too:

    string address = "https://social.msdn.microsoft.com/Forums/en-US/aafa0b78-75b9-4bb0-b00e-bcb1e987ed69";
     
    var c = new WebClient( );
    
    string html = c.DownloadString( address );

    Thursday, November 7, 2019 6:35 AM
  • Hi PKasia,

    Is your problem solved? If so, please click "Mark as answer" to the appropriate answer, so that it will help other members to find the solution quickly if they face a similar issue.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, November 14, 2019 6:35 AM
    Moderator
  • Why can't you use WebClient?

    Michael Taylor http://www.michaeltaylorp3.net

    Friday, November 15, 2019 3:20 PM
    Moderator
  • Hi PKasia,

    Is your problem solved? If so, please click "Mark as answer" to the appropriate answer, so that it will help other members to find the solution quickly if they face a similar issue.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, November 22, 2019 10:16 AM
    Moderator