python为访问网络提供了强大的支持,
我们可以使用程序自动读取网页,而urllib是完成这种任务的最佳选择。
实例:读取百度首页的网页内容
import urllib2
html=urllib2.urlopen("http://www.baidu.com")
content = html.read()
print(content)
实例2:在默认浏览器中显示雅虎的首页:
import webbrowser
webbrowser.open("http://yahoo.com")
True