how to open a url in python

shamsee picture shamsee · Nov 29, 2010 · Viewed 358.4k times · Source
import urllib

fun open():
    return urllib.urlopen('http://example.com')

But when example.com opens it does not render css or js. How can I open the webpage in a web browser?

@error(404)
def error404(error):
    return webbrowser.open('http://example.com')

I am using bottle. Giving me the error: TypeError("'bool' object is not iterable",)

Answer

aaronasterling picture aaronasterling · Nov 29, 2010

with the webbrowser module

import webbrowser

webbrowser.open('http://example.com')  # Go to example.com