python中urllib模块

打开一个url的方法,返回一个文件对象,然后可以进行类似文件对象的操作。本例试着打开google

>> import urllib
>>> f = urllib.urlopen('http://www.google.com.hk/')
>>> firstLine = f.readline()   #读取html页面的第一行
>>> firstLine
'cope="" itemtype="http://schema.org/WebPage"><Meta content="/images/google_favicon_128.png" itemprop="image">Google