我有以下代码(排除类构造函数等) - 我正在使用 PySide 顺便说一句:
self.view = QWebView()
frame = self.view.page().mainFrame()
document = frame.documentElement()
search = document.findFirst("input[name=q]")
search.setAttribute("value", "srbija")
button = document.findFirst("input[name=btnK]")
您可能已经注意到,这直接来自 google.com 主页。我正在尝试基本上搜索该页面。但我无法弄清楚点击“Google 搜索”按钮。文档仅提到 button.evaluateJavaScript("click()")
,但这仅调用 JS 方法 - 在这种情况下我不需要任何 JS 方法,我需要实际单击按钮。
最佳答案
关于python - 如何点击QWebView中的提交按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10234999/