`
yangjizhong24
  • 浏览: 395959 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

抓取网页信息

阅读更多

取得headers:

 

import httplib
conn = httplib.HTTPConnection('www.sohu.com')
conn.request('get', '/')
res = conn.getresponse()
#print res.status, res.reason


print res.getheaders()

取得内容:

  • #coding=gbk   
  • import httplib   
  • conn = httplib.HTTPConnection("www.google.cn")   
  • conn.request('get''/')   
  • print conn.getresponse().read()   
  • conn.close() 
  • 分享到:
    评论

    相关推荐

    Global site tag (gtag.js) - Google Analytics