Thomas said:
kaer said:
I have no idea what you mean, and I do know my way around XPath and
XMLHttpRequest.
I would like to be able to do something like:
import AbstractBrowser
browser=AbstractBrowser.Browser()
browser.goto('
www.somesitewithajax.com', wait_until_onload_done=True)
what_i_want= browser.XPath('/html/body/center/div/div[2]/div/div/div/
div[3]/div[2]/div[2]/div'])
[...]
[...]
With the Gecko DOM API, you can do:
var iframe = document.body.appendChild(document.createElement("iframe"));
if (iframe)
{
iframe.addEventListener("load",
function() {
var d = this.contentDocument;
var what_you_want =
d.evaluate('/html/body/...', d.documentElement, null, 0, null);
}, false);
iframe.contentWindow.location = "
http://www.somesitewithajax.com/";
}
Reviewing this, it is not going to work this way.
1. Loading the iframe means nothing about loading the iframe document.
2. The context node must be `d', not `d.documentElement', for `/html'
to work.
3. Loading the iframe document means nothing about the *A*JAX code to be
done modifying the document tree, for the very point of it is that it
is *asynchronous*.
While having the evaluation code be executed through window.setTimeout()
is a possibility, the reliable but non-trivial way would be to tap into
the `onreadystatechange' listener of the XHR object. The issue then is
to find the name of the property that refers to that object.
So it would be better but yet to be improved if you used
var iframe = document.body.appendChild(document.createElement("iframe"));
if (iframe)
{
var d = iframe.contentDocument;
d.addEventListener("load",
function() {
var t = window.setTimeout(
function() {
window.clearTimeout(t);
var what_you_want =
d.evaluate('/html/body/...', d, null, 0, null);
},
1000);
},
false);
iframe.contentWindow.location = "
http://www.somesitewithajax.com/";
}
And then there is still the issue of frame-breaking scripts running on that
site.
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee