This article has been dead for over three months
You
#!/usr/bin/env python
# -*-coding: utf8-*-
# Title: remotecontrol.py
# Author: Gribouillis
# Created: 2012-02-03 14:51:45.755655 (isoformat date)
# License: Public Domain
# Use this code freely.
""" This module allows to change or reload the content of a tab in
a running firefox instance equiped with the Remote Control addon
(see https://addons.mozilla.org/en-US/firefox/addon/remote-control)
Notice that after installing the addon, you must install a
Remote Control icon in firefox add-on bar for this to work
(right click in the menubar and choose Customize).
See the example in the __main__ section below.
"""
import sys
import telnetlib
version_info = (0, 1)
version = ".".join(map(str, version_info))
class Control(object):
def __init__(self, port=32000):
self.host = 'localhost'
self.port = port
def reload(self):
tn = telnetlib.Telnet(self.host, self.port)
tn.write("reload\n")
result = tn.read_until('\n')
return result
def load(self, url):
tn = telnetlib.Telnet(self.host, self.port)
tn.write('window.location="%s"' % url)
result = tn.read_until('\n')
return result
if __name__ == "__main__":
"This part will run after selecting a tab for remote control in firefox"
from time import sleep
c = Control()
print c.load("http://www.python.org")
sleep(1)
print c.reload()
sleep(1)
print c.load("http://www.daniweb.com")