[英]How do I edit the url in python and open a new page without having a new window or tab opened?
I am trying to create a python script that opens a single page at a time, however python + mozilla make it so everytime I do this, it opens up a new tab. 我试图创建一个python脚本,一次打开一个页面,但是python + mozilla做到了,因此每次我这样做时,它都会打开一个新标签页。 I want it to keep just a single window open so that it can loop forever without crashing due to too many windows or tabs.
我希望它只打开一个窗口,以便它可以永久循环而不因过多的窗口或选项卡而崩溃。 It will be going to about 6-7 websites and the current code imports time and webbrowser.
它将去大约6-7个网站,并且当前代码导入时间和网络浏览器。
webbrowser.open('url') time.sleep(100) webbrowser.open('next url') webbrowser.open('url')time.sleep(100)webbrowser.open('next url')
//but here it will open a new tab, when I just want it to change the page. //但是当我只想更改页面时,它将在这里打开一个新标签。
Any information would be greatful, 任何信息都非常有用,
Thank you. 谢谢。
In firefox, if you go to about:config and set browser.link.open_newwindow to "1", that will cause a clicked link that would open in a new window or tab to stay in the current tab. 在firefox中,如果转到about:config,并将browser.link.open_newwindow设置为“ 1”,则将使在新窗口或选项卡中打开的单击链接保持在当前选项卡中。 I'm not sure if this applies to calls from 3rd-party apps, but it might be worth a try.
我不确定这是否适用于来自第三方应用程序的呼叫,但可能值得尝试。
Of course, this will now apply to everything you do in firefox (though ctrl + click will still open links in a new tab) 当然,这现在将适用于您在firefox中所做的一切(尽管按Ctrl +单击仍会在新选项卡中打开链接)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.