Rasika Perera Govinnage
Rasika Perera Govinnage

Reputation: 2254

Epiphany browser open URLs in the same tab in python

I am using epiphany webbrowser in my Raspberry Pi project. According to the requirement I need to open a link on the same tab using python webbrowser module. But each time a new tab is opened although I've given the parameter new=0

import webbrowser
import time
b = webbrowser.get('epiphany')
b.open('http://www.google.com', new=0)
time.sleep(5)
b.open('https://stackoverflow.com', new=0)

Any way to resolve this? I need to open urls on the same tab. Any solution from the webbrowser's perspective or python webbrowser module's perspective is highly appreciated.

Upvotes: 3

Views: 2625

Answers (1)

devopsfool
devopsfool

Reputation: 25

i had the same problem with epiphany, get yourself firefox(iceweasel) for raspbian(is anyway quicker):

sudo apt-get install iceweasel

then you need to install selenium

pip install selenium

i tested this snippet on pi2+:

import selenium.webdriver as webdriver
from time import sleep

if __name__ == "__main__":
    urls = ['http://192.168.0.1', 'http://192.168.0.2','http://192.168.0.3']

b = webdriver.Firefox()

while True:
    for idx, url in enumerate(urls):
        b.maximize_window()
        b.get(url)
        sleep(20)

the only issue is that it opens an new window once and then loads your urls in the same tab, if that's good enough for you.

Upvotes: 3

Related Questions