Issue In Invoking "onclick" Event Using PyQt & Javascript
Solution 1:
I think there is a problem with your JavaScript code. Since you're creating a MouseEvent
object you should use an initMouseEvent
method for initialization. You can find an example here.
UPDATE2
But I think the simplest think you can try is to use the JavaScript DOM method onclick
of the a
element instead of using your own JavaScript code. Something like this:
allButton.evaluateJavaScript("this.onclick()")
should work. I suppose you will have to reload the page after clicking, before passing it to the parser.
UPDATE 3
You can reload the page via r.action(QWebPage.ReloadAndBypassCache)
or r.action(QWebpage.Reload)
but it doesn't seem to have any effect. I've tried to display the page with QWebView
, click the link and see what happens. Unfortunately I'm getting lots of Segmentation Fault errors so I would swear there is a bug somewhere in PyQt4/Qt4. As the page being scrapped uses jquery I've also tried to display it after loading jquery in the QWebPage
but again no luck (the segfaults do not disappear). I'm giving up :( I hope other users here at SO will help you. Anyway I recommend you to ask for help to the PyQt4 mailing list. They provide excellent support to PyQt users.
UPDATE
The error you get when changing your code is expected: remember that allButton
is a QWebElement
object. And the QWebElement.evaluateJavaScript
method returns a QVariant
object (as stated in the docs) and that kind of objects don't have a webFrame
attribute as you can check reviewing this page.
Post a Comment for "Issue In Invoking "onclick" Event Using PyQt & Javascript"