简体   繁体   English

如何在python中编辑url并打开新页面而不打开新窗口或标签?

[英]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.

相关问题 阅读在新标签中打开的 window 的页面源 - Read page source of window opened in new tab 如何在webdriver(Python)中打开一个新窗口或选项卡? - How to open a new window or tab in webdriver (Python)? 如何在selenium python中获取新打开的标签的链接和页面信息 - How to get link and page information of new opened tab in selenium python 如何使用 python selenium 在新选项卡中打开链接而不知道其 URL - How to open a link without knowing its URL in new tab using python selenium 如何使用 eel(python 库)打开一个新的 HTML 页面? - How do I open a new HTML page with eel (python library)? Python + Selenium WebDriver:在新标签页中打开URL - Python + Selenium WebDriver: open URL in new tab Python和Selenium,无法使用URL打开新标签页吗? - Python and selenium, is not possible to open a new tab with a URL? 窗口不会在外部 url 链接点击上打开新窗口或标签 - Window does not open new window or tab on external url link click 打开新的cmd窗口后,如何从python3批处理文件在终端中推送命令? - How to push in a command in terminal from a python3 batch file after having opened a new cmd window? 如何在不打开新标签(python)的情况下更改Selenium中的URL? - How to change URL in Selenium without opening new tab (python)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM