Re: open URL in the current tab

Discussion in 'Python' started by Jabba Laci, Dec 11, 2012.

  1. Jabba Laci

    Jabba Laci Guest

    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')
     
    Jabba Laci, Dec 11, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jabba Laci

    open URL in the current tab

    Jabba Laci, Dec 10, 2012, in forum: Python
    Replies:
    0
    Views:
    122
    Jabba Laci
    Dec 10, 2012
  2. Joel Goldstick

    Re: open URL in the current tab

    Joel Goldstick, Dec 10, 2012, in forum: Python
    Replies:
    0
    Views:
    123
    Joel Goldstick
    Dec 10, 2012
  3. Boris FELD

    Re: open URL in the current tab

    Boris FELD, Dec 10, 2012, in forum: Python
    Replies:
    0
    Views:
    135
    Boris FELD
    Dec 10, 2012
  4. Jabba Laci

    Re: open URL in the current tab

    Jabba Laci, Dec 10, 2012, in forum: Python
    Replies:
    0
    Views:
    139
    Jabba Laci
    Dec 10, 2012
  5. Chris Angelico

    Re: open URL in the current tab

    Chris Angelico, Dec 10, 2012, in forum: Python
    Replies:
    0
    Views:
    157
    Chris Angelico
    Dec 10, 2012
Loading...

Share This Page