import urllib
fun open[]:
return urllib.urlopen['//example.com']
But when example.com opens it does not render CSS or JavaScript. How can I open the webpage in a web browser?
@error[404]
def error404[error]:
return webbrowser.open['//example.com']
I am using bottle. Giving me the error:
TypeError["'bool' object is not iterable",]
Syscall
18.3k10 gold badges32 silver badges49 bronze badges
asked Nov 29, 2010 at 8:36
5
with the webbrowser module
import webbrowser
webbrowser.open['//example.com'] # Go to example.com
rmmh
6,90125 silver badges37 bronze badges
answered Nov 29, 2010 at 8:37
aaronasterlingaaronasterling
66.5k20 gold badges123 silver badges125 bronze badges
1
import webbrowser
webbrowser.open[url, new=0, autoraise=True]
Display url using the default browser. If new is 0, the url is opened in the same browser window if possible. If new is 1, a new browser window is opened if possible. If new is 2, a new browser page [“tab”] is opened if possible. If autoraise is True, the window is raised
webbrowser.open_new[url]
Open url in a new window of the default browser
webbrowser.open_new_tab[url]
Open url in a new page [“tab”] of the default browser
answered Sep 25, 2013 at 10:19
impimp
1,8332 gold badges27 silver badges39 bronze badges
On Windows
import os
os.system["start \"\" //example.com"]
On macOS
import os
os.system["open \"\" //example.com"]
On Linux
import os
os.system["xdg-open \"\" //example.com"]
Cross-Platform
import webbrowser
webbrowser.open['//example.com']
answered Sep 11, 2018 at 21:52
abrahamcalfabrahamcalf
6,6423 gold badges40 silver badges51 bronze badges
You have to read the data too.
Check out : //www.doughellmann.com/PyMOTW/urllib2/ to understand it.
response = urllib2.urlopen[..]
headers = response.info[]
data = response.read[]
Of course, what you want is to render it in browser and aaronasterling's answer is what you want.
answered Nov 29, 2010 at 8:37
pyfuncpyfunc
63.7k15 gold badges146 silver badges135 bronze badges
You could also try:
import os
os.system["start \"\" //example.com"]
This, other than @aaronasterling ´s answer has the advantage that it opens the default web browser. Be sure not to forget the "//".
answered Feb 20, 2016 at 21:03
Here is another way to do it.
import webbrowser
webbrowser.open["foobar.com"]
answered Oct 9, 2016 at 12:59
DocJ457DocJ457
6797 silver badges16 bronze badges
I think this is the easy way to open a URL using this function
webbrowser.open_new_tab[url]
Pang
9,132146 gold badges84 silver badges118 bronze badges
answered Nov 16, 2017 at 23:08