0

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.

2 Answers 2

1

The DOM is exposed (at least in pyqt >= 4.7.4)

document = webview.page().currentFrame().documentElement()
document.findAll("a") 
...

http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qwebframe.html

http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qwebelement.html

Sign up to request clarification or add additional context in comments.

Comments

0

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

import ghost
g = ghost.Ghost()
g.open('http://stackoverflow.com/')

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

g.main_frame.setContent('<b>Hello World</b>')

can be used to set the document, while

g.content = '<b>Hello World</b>'

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.