admin管理员组文章数量:1355529
I can't use Selenium
or any other type of option that controls the browser, because I need to use it on sites that have strict restrictions against bots and automations, so I need to use the browser itself as it is originally.
I currently use the following pattern code to open websites:
import webbrowser
url = f"/"
webbrowser.get("C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe %s").open(url)
With the web page already open in my browser, I have two extensions that I click to open the same window but as a pop-up, each extension has a different pop-up style, but both do not take up as much space as the browser's own options at the top of the page:
I would like to know if there is any way to specify in the Python code that I want to open as a pop-up or a normal tab so that I don't have to manually convert them using browser extensions.
I can't use Selenium
or any other type of option that controls the browser, because I need to use it on sites that have strict restrictions against bots and automations, so I need to use the browser itself as it is originally.
I currently use the following pattern code to open websites:
import webbrowser
url = f"https://www.google/"
webbrowser.get("C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe %s").open(url)
With the web page already open in my browser, I have two extensions that I click to open the same window but as a pop-up, each extension has a different pop-up style, but both do not take up as much space as the browser's own options at the top of the page:
I would like to know if there is any way to specify in the Python code that I want to open as a pop-up or a normal tab so that I don't have to manually convert them using browser extensions.
Share Improve this question edited Mar 28 at 15:13 Digital Farmer asked Mar 28 at 15:00 Digital FarmerDigital Farmer 2,1796 gold badges25 silver badges98 bronze badges1 Answer
Reset to default 2Yes, but with limitations. You can launch Microsoft Edge using Python’s webbrowser
or subprocess
, but to open a pop-up style window, you need to use Edge command-line arguments.
Use --app
or --window-size
flags for a minimal pop-up-like window.
Example using subprocess
(more flexible than webbrowser
):
# PYTHON
import subprocess
url = "https://www.google/"
edge_path = "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
# This creates a minimal window like a popup (no tabs, no address bar)
subprocess.Popen(\[edge_path, f'--app={url}'\])
What does --app=
do?
It opens the URL as a web app window (no address bar, no tabs, no menu).
This is exactly what extensions like “Popup View” or “Open-as-Popup” do under the hood.
Optional Extras:
You can control size and position:
subprocess.Popen([ edge_path, f'--app={url}', '--window-size=800,600', '--window-position=100,100' ])
Summary
→ TaskSolutionOpen in normal
tabwebbrowser.get(...).open(url)
Open in popup/app modeUsesubprocess
+--app=
flagAvoid bot detection:
✅ Yes→ This is indistinguishable from manual actionWorks with Edge extensions?
✅ Yes, browser is standard.
本文标签: Open a webpage popup window in Microsoft Edge browser using Python without SeleniumStack Overflow
版权声明:本文标题:Open a webpage popup window in Microsoft Edge browser using Python without Selenium - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744029774a2578691.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论