Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #34584

Re: open URL in the current tab

References <CAOuJsM=ch3T=L3+7rQ=sg5t_LmA5v_nXJLYYTw7ySD30Vmx+qA@mail.gmail.com> <CAPTjJmp3Hpw9_FW9h2S9ga3bZU4FeULUFUeyWKuOgT8FeRLuxg@mail.gmail.com>
From Jabba Laci <jabba.laci@gmail.com>
Date 2012-12-11 01:05 +0100
Subject Re: open URL in the current tab
Newsgroups comp.lang.python
Message-ID <mailman.696.1355184377.29569.python-list@python.org> (permalink)

Show all headers | View raw


Hi,

> If this is for use on somebody else's system, *please don't*. My

This is for me. I have a simple GUI that produces some URL that I want
to open in the current tab. Since I want to verify several URLs, I
don't want to open dozens of new tabs.

Here is my working solution. It requires the MozRepl Firefox add-on
that I mentioned in the previous message.

Laszlo

===========================

import telnetlib

HOST = 'localhost'
PORT = 4242    # MozRepl default

def open_curr_tab(url):
    tn = telnetlib.Telnet(HOST, PORT)
    cmd = "content.location.href = '{url}'".format(url=url)
    tn.read_until("repl> ")
    tn.write(cmd + "\n")
    tn.write("repl.quit()\n")

#########################

if __name__ == "__main__":
    open_curr_tab('http://www.python.org')

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: open URL in the current tab Jabba Laci <jabba.laci@gmail.com> - 2012-12-11 01:05 +0100

csiph-web