cefsharp / CefSharp

.NET (WPF and Windows Forms) bindings for the Chromium Embedded Framework
http://cefsharp.github.io/
Other
9.87k stars 2.92k forks source link

GetSource returns incomplete HTML #1864

Closed aradzu10 closed 7 years ago

aradzu10 commented 7 years ago

I'm using in my project Cefsharp. I want to get the html source of a page after the page done loading. So Im using this code:

    private void WebBrowserFrameLoadEnded(object sender, FrameLoadEndEventArgs e)
    {
        if (e.Frame.IsMain)
        {
            //chromeBrowser.ViewSource();
            chromeBrowser.GetSourceAsync().ContinueWith(taskHtml =>
            {
                var html = taskHtml.Result;
            });
        }
    }

And I saw that the line "chromeBrowser.ViewSource();" opens me a notepad with the source file. But I don't get the same "file"/text in my html variable. I would like to get what Im getting from the ViewSource() and not from GetSourceAsync().

How can I do that?

GrabzIt commented 7 years ago

This does not sound like a bug, although as this is a wrapper it would most likely be upstream issue. So I am not sure why you have reported it as such. If you have a question, you should ask it on Gitter, post on StackOverflow or use http://magpcss.org/ceforum/ (for questions specific to CEF).

amaitland commented 7 years ago

What URL reproduces this problem? What version are you using? Please use the Bug Report template when posting an issue. https://github.com/cefsharp/CefSharp/blob/master/ISSUE_TEMPLATE.md#bug-report

Looking at the CEF implementation it's likely timing related, try adding a menu item to your app that gets the source, wait a few seconds for your page to load before clicking and see what result you get.

You can call GetSource on the frame directly and use your own implementation of IStringVisitor https://github.com/cefsharp/CefSharp/blob/cefsharp/53/CefSharp/IFrame.cs#L75 to debug the problem, your probably best downloading the project source to do this.

amaitland commented 7 years ago

Closing due to lack of feedback.

amaitland commented 7 years ago

As this appears to be a bug in CEF, someone will have to post on http://magpcss.org/ceforum/ It's important that you provide a URL that demonstrates your problem.

Once you've posted on http://magpcss.org/ceforum/ then post a link here.

YSFKBDY commented 7 years ago

I've created a post on Supoort Forum, but it needs to be approved it says. After that, I'll post the link here.

YSFKBDY commented 7 years ago

http://magpcss.org/ceforum/viewtopic.php?f=6&t=15063

zankhanarana9 commented 5 years ago

I am having the same problem. The HTML content from Viewsource and GetSourceAsync are different. and it looks like the one returned on GetsourceAsync is incomplete. How did you solve it?

mkamoski commented 2 years ago

Yes, this is bug, in the latest version as of now. Here is a url example... https://www.mercari.com/search/?itemStatuses=1&keyword=dam%20troll&sortBy=2 ...but it happens with any large page. The View Source (manual in the ui) and a GetSourceAsync (sp?) in code both are not working as they should. That url has hundreds of listings. But the View source returns only about 30 at the most. Tried browser.refresh no luck, tried page all the way down no luck, tried forced pause after ever page down no luck, tried page-all-the-way-down and then page-all-the-way-up and then view source (or getsourceasync) no luck. This is definitely a bug, or "view source" and "getsourceasync" need a new (non-standard) definition. Anyway, I would love to see a fix, or be proven wrong on this, but such as it is it definitely looks like a bug to me. Thanks. -- Mark

amaitland commented 2 years ago

The View Source (manual in the ui) and a GetSourceAsync (sp?) in code both are not working as they should.

CefSharp is just a wrapper around the Chromium Embedded Framework.

If code changes are required then they would need to be made in CEF or Chromium.

If you can reliably reproduce the issue with the current supported version then please create an issue on the CEF Issue Tracker.

For reference