Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi everyone

I have made a browser with cefsharp chromium and want to save html or to open it on textbox.

Tried:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    browser.ViewSource()
End Sub

And after that, html is like i want, outputed on a notepad file at temp data with a randnom name.
I want to save him automatically at ex. "C:\" with a name.htm (txt) OR to see it on a textbox, or to find what name will have this txt on tempdata.

Hope to find a solution, Please help me. Thanks :)

What I have tried:

Imports CefSharp.WinForms
Imports CefSharp

Public Class Form1

    Private WithEvents browser As ChromiumWebBrowser

    Public Sub New()
        InitializeComponent()

        Dim settings As New CefSettings
        CefSharp.Cef.Initialize(settings)

        browser = New ChromiumWebBrowser("url") With {
            .Dock = DockStyle.Fill
        }
        Panel1.Controls.Add(browser)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        browser.ViewSource()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        browser.Load(TextBox1.Text)
    End Sub

End Class
Posted
Updated 4-Mar-23 3:29am
v3
Comments
Member 15627495 4-Mar-23 12:17pm    
the webBrowser class is a good starting point ( for the diplay too ),
you have the DOM page to pick, put it in a Var(String) or in a Html Object.
you'll be able to fetch the DOM, seeing all tags as code Html.
Richard Deeming 6-Mar-23 4:05am    
The WebBrowser class represents an instance of Internet Explorer.

Worse, it's stuck in IE7 rendering mode unless you modify the registry on every computer where your application runs. Meaning it won't be able to load or render most modern websites.

The OP is using CefSharp, which is an instance of Chromium - the same rendering engine used by Google Chrome and Microsoft Edge. Suggesting that they switch back to an outdated control that won't work with most websites is not a good idea.
Member 15627495 6-Mar-23 4:09am    
there are few solutions, WebBrowser Class can be visible = false, and a software will get back all DOM of pages for later.

It's only the rendering which is 'hard' sometimes, but not the whole code of the page DOM.

you're right Richard Deeming, but WebBrowser will act as 'gateway'

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900