How to read Mozrepl Javascript result into a Python Variable?

goldtech leegold at operamail.com
Sat Jul 13 22:49:46 CEST 2013


Hi,

With Mozrepl addon in Firefox and Python I do:

>>> import telnetlib
>>> tn = telnetlib.Telnet(r'127.0.0.1', 4242, 5)
>>> tn.read_eager()
'\nWelcome to MozRepl.\n\n - If you get stuck at the "'
>>> tn.read_until("repl> ")
...snip...
>>> tn.write(r'alert(window.content.location.href)'+"\n")

and I get an alert box with the URL of the active tab. 

But how do I read that URL into a python variable? Something like tn.write(r';var zz = window.content.location.href'+ "\n") but that doesn't get it into python. 

I would be grateful for help. Thanks.
 



More information about the Python-list mailing list