PyQtWebkit 和 java 脚本
我有一个带有js的页面。 我需要在网页执行js后获取dom。 Js 在名为“sdl”的 div 中插入文本。 我需要获取 之间的值。 Value不能在js源码中解析,它是由Js生成的。 怎么做呢? 对不起我的英语。
I have a page with js.
I need get dom after js execute at webpage.
Js inserts text in the div with name 'sdl'.
I need get value between . Value can not be parsed in js source, it is generated by Js.
How to do it?
Sorry for my english.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
DOM 被暴露(至少在 pyqt >= 4.7.4 中)
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qwebframe.html
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qwebelement.html
The DOM is exposed (at least in pyqt >= 4.7.4)
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qwebframe.html
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qwebelement.html
在 Python 中,您可以使用 Ghost,它是开源的,可以从 github 获取。它是围绕 PyQt4+WebKit hack 的 Python 包装器,运行得非常好。你现在可以做
g.content
引用文档,渲染后。您还可以使用
evaluate
方法评估文档中的 JS,它会返回 JS 值。Ghost 还很容易公开 PyQt 对象,因此您可以对 Ghost 未实现的 Ghost 对象执行一些操作,并且它会通过。
我记不太清了,但我认为类似的东西
可以用来设置文档,同时
抛出一个。这需要一些驯服,但不需要很长时间就能让它按照您想要的方式工作。
Ghost 文档很糟糕,但源代码是一个文件并且非常具有解释性。我用的是Ghost,没问题。只是不要创建多个
Ghost
对象,否则它往往会导致一切崩溃。In Python, you can use Ghost, which is open source and available from github. It's a Python wrapper around the PyQt4+WebKit hack that works pretty well. You can just do
Now
g.content
refers to the document, post-rendering.You can also evaluate JS in the doc with the
evaluate
method, and it'll return the JS values.Ghost also exposes the PyQt objects pretty readily, so you can do stuff to a
Ghost
object that Ghost doesn't implement, and it'll pass through.I can't remember exactly, but I think something like
can be used to set the document, while
throws one. It takes some taming, but it doesn't take long to get it working how you want it to.
The Ghost docs suck, but the source is a single file and pretty explanatory. I use Ghost and it's fine. Just don't create more than one
Ghost
object, else it tends to crash everything.