Questions tagged [python-webbrowser]

Python module that allows the user to load web content with available browsers.

The webbrowser module provides a high-level interface to allow displaying web-based documents to users. Under most circumstances, simply calling the open() function from this module will do the right thing.

More info: https://docs.python.org/3/library/webbrowser.html

406 questions
4
votes
0 answers

webbrowser.open() doesn't display the web page when we call python script file somewhere in html code

I have some python code below that will open an exist web page if the condition occurs.. I have tried this code in IDLE , it works fine but when I call the python file in somewhere in html code unfortunately it does not display the web page which…
4
votes
2 answers

How to open a web browser with specific URL on local machine when script is running on virtual machine?

I am connecting to virtual machine with putty ssh from my local machine and running a python script on virtual machine. From the script, I want to open a web browser with specific URL on my local machine. Is it possible to do so with…
npatel
  • 1,081
  • 2
  • 13
  • 21
4
votes
2 answers

Why is bash (WSL) using w3m as it's default browser?

Bash on Ubuntu on Windows 10 is using w3m to open URLs inside the terminal instead of opening Chrome or Edge. How can I get it to launch the Windows default web browser? For example, the following…
4
votes
3 answers

Open a HTML file with Python using Firefox when Firefox isn't the default browser

I've seen a few questions related to this, but I'm still having trouble. Running the code: >>>webbrowser.get('firefox') errors with: webbrowser.Error: could not locate runnable browser To troubleshoot I…
RussellB.
  • 346
  • 1
  • 3
  • 9
4
votes
2 answers

How to set BROWSER environmental variable for python webbrowser

I'm trying to register the Firefox browser to run on Windows. According to the documentation for Webbrowser, "If the environment variable BROWSER exists, it is interpreted to override the platform default list of browsers, as a os.pathsep-separated…
user1592380
  • 34,265
  • 92
  • 284
  • 515
4
votes
1 answer

Unable to display Japanese (UTF-8) characters in email body with webbrowser

I am reading text from two different .txt files and concatenating them together. Then add that to a body of the email through by using webbrowser. One text file is English characters (ascii) and the other Japanese (UTF-8). The text will display…
tokyovariable
  • 1,656
  • 15
  • 23
3
votes
4 answers

Opening a new unfocused tab in Chrome or Firefox with Python on Windows OS

My OS → Microsoft Windows 11 GOOGLE CHROME: I have Google website open and I want to open the Stack Overflow website in a new tab but the screen keeps showing the Google website, like this: My first attempt was trying it with the webbrowser module…
Digital Farmer
  • 1,705
  • 5
  • 17
  • 67
3
votes
1 answer

Pythons Webbrowser Module Will Never Open a Link in a new Window

I was trying to automate opening multiple user profiles given a list of names on a few different sites but i can not find a way to open a link in a new window meaning i can not sort the different sites i am opening into their own window collection.…
nizzy2k11
  • 31
  • 4
3
votes
1 answer

Open HTML file in same tab using python script

I am trying to open a HTML page using python script. With the following script the file opens in a new browser tab. How should I make it open in the same tab? import webbrowser import os import urllib chrome_path="C:\\Program Files…
ron123456
  • 153
  • 8
3
votes
4 answers

In Python, how to open a string representing HTML in the browser?

I'd like to view a Django template in the browser. This particular template is called in render_to_string, but is not connected to a view, so I can't just runserver and navigate to the URL at my localhost. My idea was to simply call render_to_string…
Kurt Peek
  • 52,165
  • 91
  • 301
  • 526
3
votes
1 answer

python: open unfocused tab with webbrowser

I would like to open a new tab in my web browser using python's webbrowser. However, now my browser is brought to the top and I am directly moved to the opened tab. I haven't found any information about this in documentation, but maybe there is some…
gruszczy
  • 40,948
  • 31
  • 128
  • 181
3
votes
4 answers

Python 2.7 changing default browser for webbrower.open

I am trying to open a page a wrote and saved to a local server. Everything is great but it defaults to opening in IE instead of Chrome. Chrome is my default browser and couldn't find any helpful tips online. Sample code: import…
user3681278
  • 135
  • 1
  • 4
  • 11
3
votes
1 answer

How to open a url through python code on mac osx

I want to open a url through python code on mac osx. I am using safari. I tried webbrowser.open(url,new=1,autoraise=True) , webbrowser.open(url), webbrowser.open_new(url), webbrowser.open_new_tab(url). Sometimes, a new tab will open, Sometimes it…
user2899498
  • 31
  • 1
  • 3
2
votes
1 answer

For loop in WebBrowser module doesn't work

I have some links in a list and I need to open all these links in my browser import webbrowser browserpath='C:\Program Files (x86)\Google\Chrome\Application\chrome.exe %s' lis=[ITS FILLED WITH LINK ADDRESSES] for site in lis: …
Lesbian
  • 21
  • 3
2
votes
1 answer

Python script in VS code using python standard library webbroswer works only while using debugger extension

I am using VS code, Visual code extension for debugging (showing the state of the code, putting marks where to run before running line by line and always showing the state of the parameters etc..) and I am trying to think how I should begin to check…
1 2
3
27 28