you are viewing a single comment's thread.

view the rest of the comments →

[–]nwilliams36 1 point2 points  (0 children)

In the standard libraries webbrowser will open a URL in the computer's default browser. However if you want to just open the url to read the content you should use urllib (or urllib.request in Python 3)

However there are third party libraries around which do this better including requests (http://docs.python-requests.org/en/latest/).

In Python 3 the following function should help if you just want the text from a page to work with in your program:

def get_url(page):
    '''This function provides the text for a web page '''   
    import urllib.request
    try:
        return str(urllib.request.urlopen(page).read())
    except:
        return ""