简体   繁体   English

避免在PySide QT4中使用shouldInterruptJavaScript-Python

[英]Avoid shouldInterruptJavaScript in PySide QT4 - Python

I am using PySide '1.2.2' and trying to avoid the msgbox alerting a potential javascript error, since it is due to the site being sizeable. 我正在使用PySide'1.2.2'并试图避免msgbox发出潜在的JavaScript错误警报,因为这是由于网站很大。 I am using this code from this other answer: 我正在从另一个答案中使用此代码:

Override shouldInterruptJavaScript in QWebPage with PySide 用PySide覆盖QWebPage中的shouldInterruptJavaScript

import sys
from PySide import QtCore
from PySide.QtGui import QApplication
from PySide.QtWebKit import QWebPage

class QWebPageHeadless(QWebPage):
    # FIXME: This is not working, the slot is not overriden!
    @QtCore.Slot()
    def shouldInterruptJavaScript(self):
        print( 'not interrupting')
        return False

I have tried implementing the class above, and all sorts of derivatives of it, but with no success, it never gets to execute. 我已经尝试实现上述类以及它的各种派生类,但是没有成功,它永远无法执行。 Any thoughts on how to do this? 有关如何执行此操作的任何想法? Thank you 谢谢

I found the "solution". 我找到了“解决方案”。 Forget about PySide and PyQt, you will just end up with headaches, use Selenium. 忘了PySide和PyQt,您最终会头疼,请使用Selenium。 Very easy to implement and powerful for this purpose. 为此非常容易实现且功能强大。 Works great! 很棒!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM