I tried following code in VS2015, Eclipse and Spyder:
import urllib.request
with urllib.request.urlopen('https://www.python.org/') as response:
html = response.read()
In call cases it won't open the webpage in the browser. I am not sure what is the problem. Debug won't help. In VS2015 the program exists with code 0 which I suppose means successful.
You are using wrong library for the job. urllib module provides functions to send http requests and capture the result in your program. It has nothing to do with a web browser. What you are looking for is the webbrowser module. Here is an example:
import webbrowser
webbrowser.open('http://google.com')
This will show the web page in your browser.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With