Python open webpage in chrome
According to the documentation http://docs.python.org/3.3/library/webbrowser.html it's supposed to open in the default browser, but for some reason on my machine it opens IE. I did a google search and I came across an answer that said I need to register browsers, but I'm not sure how to use webbrowser.register() and the documentation doesn't seem to be very clear. How do I register Chrome so that urls I pass to webbrowser.open() open in Chrome instead of IE? Show asked Mar 17, 2014 at 0:50
1 You can call get() with the path to Chrome. Below is an example - replace chrome_path with the correct path for your platform.
Hassan Saeed 5,2671 gold badge30 silver badges34 bronze badges answered Jun 22, 2014 at 17:28
Chad JonesChad Jones 1,2811 gold badge10 silver badges3 bronze badges 6
you can use any other browser by changing the parameter 'using' as given in a link answered Apr 24, 2017 at 21:21
njn1234njn1234 3312 silver badges5 bronze badges 1 Please check this:
answered Jun 19, 2019 at 10:45
worked for me to open new tab on google-chrome:
answered Sep 24, 2019 at 2:02
qloveshmilyqloveshmily 9318 silver badges5 bronze badges Here's a somewhat robust way to get the path to Chrome. (Note that you should do this only if you specifically need Chrome, and not the default browser, or Chromium, or something else.)
answered May 26, 2019 at 8:10
user541686user541686 200k120 gold badges513 silver badges864 bronze badges 3 One thing I noticed and ran into problems with were the slashes, in Windows you need to have two of them in the path an then this works fine.
This at least works for me answered Jan 11, 2021 at 7:08
you can also use this:
answered Mar 16, 2021 at 17:22
1 Worked for me in windowsPut the path of your chrome application and do not forget to put th %s at the end. I am still trying to open the browser with html code without saving the file... I will add the code when I'll find how.
>>> link to: [a page from my blog where I explain this]<<<
user7290573 1,3191 gold badge7 silver badges13 bronze badges answered Apr 19, 2018 at 5:15
PythonProgrammiPythonProgrammi 21k3 gold badges39 silver badges34 bronze badges If you have set the default browser in windows then you can do this:
answered Jul 5, 2019 at 14:58
1 Made this for a game I play, it was relevant so i'm leaving it. It's real simple. Grabs the value from platform.system. Checks it against known values for different operating systems. If it finds a match it sets the chrome path for you. If none are found it opens default browser to your link. Hope its useful to someone.
I actually changed it some more here it is updated since I am still working on this launcher
answered Nov 22, 2019 at 6:48
answered May 31, 2020 at 8:07
SSCSWAPNILSSCSWAPNIL 5495 silver badges6 bronze badges I found an answer to my own question raised by @mehrdad's answer below. To query the browser path from Windows in a generic way @mehrdad gives a nice short code that uses the Windows Registry, but did not include quite enough context to get it working.
Thanks for the answer @mehrdad !! answered Nov 29, 2019 at 8:36
When you have an invalid URL (make sure that the url starts with https:// or http://, and if it doesn't, add it), it generally opens defaults IE. answered Mar 22, 2021 at 21:34
KetZoomerKetZoomer 2,4863 gold badges14 silver badges37 bronze badges Something like this should work:
KetZoomer 2,4863 gold badges14 silver badges37 bronze badges answered Jun 23, 2017 at 7:35
Logan MLogan M 971 silver badge3 bronze badges 2 believe me or not this is the easiest way to do
take this url for example
if you will give this url: https://something.com or something.com it will be opened in IE But if you will type it in this way: www.something.com it will be opened in chrome You can try this and this will work! (NOTE: If it has some another suffix like take https://meet.google.com for example if you try to add www. to it, your browser will throw a typo error ) answered Mar 26, 2021 at 11:42
PrabhavDevoPrabhavDevo 1,3606 silver badges21 bronze badges I think I found a workaround too
Dharman♦ 28k21 gold badges75 silver badges127 bronze badges answered Oct 11, 2021 at 16:20
Paul LamPaul Lam 1462 silver badges11 bronze badges Uhh...Hey You can Quickly Solve this Issue By adding https:// Lemme Show it Below -
answered Mar 3 at 12:56
In Selenium to get the URL of the active tab try,
Sending a signal to change the tab
and again use
I am here just providing a pseudo code for you. You can put this in a loop and create your own flow. I new to Stackoverflow so still learning how to write proper answers.
nick 1,0321 gold badge11 silver badges24 bronze badges answered Jun 28, 2017 at 10:24
Aman RapariaAman Raparia 4441 gold badge5 silver badges13 bronze badges at least in Windows it has to be enough and you do not have to take care about path to the browser.
Note: With the above lines of code, it only opens in windows defualt browser(Microsoft Edge).
answered Jun 11, 2017 at 15:29
How do I run a Python website in Chrome?python open google. #Open google in python - Windows.. import webbrowser.. url='https://google.com'. webbrowser. get('C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s'). open(url). How do I open a website in a specific browser using Python?To open a page in a specific browser, use the webbrowser. get() function to specify a particular browser.
How do I open a Python html file in Chrome?Approach:. Import module.. Open and Create file.. Add html code.. Write code to file.. Close file.. Open file in browser window.. How open html file in browser using Python?Try specifying the "file://" at the start of the URL. the 2nd example doesn't work, just us the full path to the html file without the file:// prefix. To open a URL in a new tab also webbrowser. open_new_tab(url) could be used.
|