How can I open a URL? Ask Question

How can I open a URL? Ask Question

I have some code like:

import urllib

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

But this doesn't render CSS or JavaScript from the page.

How can I use Python to open the URL in a browser, so that I can see the page properly?

ベストアンサー1

with the webbrowser module

import webbrowser

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

おすすめ記事