Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[SOLVED] Problems with framecapture example with async JS code
kubaall last edited by kubaall
I am new to Qt and Webkit and definitely I am doing something wrong. What I need is to programatically save a webpage, preferably both as an image and as HTML. I started with Qt tutorials. When I run the browser examples everything works just fine. My page loads well, aslo the flash plugin is working when I change the EnablePlugins parameter and this is what I need. However, I do not need a UI so I went on with the frame capture example and this is where the problems started.
Simple pages are captured fine, but when I try to load something more complex (for example http://onet.pl) most of the content is not loaded. After short investigation my guess is that this is because some of the content including some articles, ads etc. is loaded asynchroniosly by a JS code. From what I read about loadFinished signal
"This signal is independant of script execution or page rendering"
So here are my two questions. One probably trivial, the other probably not so trivial.
- How can I modify the framecapture example so it waits a predefined amout of time until the dynamic content is loaded? I tried to put a Sleep() call in the saveResult() function but it does not seem to change anything. I even made a simple test page with one timer displayed by PHP code after the page is loaded and the other timer being a JS timer. No matter how long I sleep, after the page is saved to PNG both times are almost equal.
- Assuming someone will provide an answer to my first question - how should I determine if my page loaded completely? Are there any good practices on that? Is it possible to check what scripts are still running?
kubaall last edited by
Thanks p3co, it does indeed answer my second question. I will try it, however my solution should be generic as I will be checking lots of different pages. Waiting a predefined time seems not such a bad idea, especially that I do not have to worry about performance at this point in time. It is just a proof of concept for the moment.
What about the first question? If I would just want to wait 30s and then save the page? How can I do that?
kubaall last edited by
Great, it worked perfectly. Thank you very much for your help!