码迷,mamicode.com
首页 > Web开发 > 详细

urllib使用二

时间:2018-06-06 23:50:37      阅读:235      评论:0      收藏:0      [点我收藏+]

标签:col   mail   http   int   message   pen   www   bsp   urlopen   

urlopen方法返回一个html

对html使用info()方法返回HTTPMessage对象实例

import urllib

def print_list(lists):
    for i in lists:
        print(i)
html = urllib.urlopen("http://www.runoob.com/python/python-email.html")
#info()方法返回HTTPMessage实例
msg = html.info()
#HTTPMessage实例的方法:
#headers
#gettype()
#getheader()/getheaders()
#items()/keys()/values()
print_list(msg.headers)

 

urllib使用二

标签:col   mail   http   int   message   pen   www   bsp   urlopen   

原文地址:https://www.cnblogs.com/chillytao-suiyuan/p/9147655.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!