Python--初识Requests库 Hooks

# -*- coding: utf-8 -*-
# @Time : 2017/12/2 0006 10:26
# @Author : wangyafeng
# @Email : 279949848@qq.com
import requests

def get_key(response,*args,**kwargs):
print(response.headers['Content-Type'])



def myresponse():
url="https://www.sina.com.cn"
requests.get(url,hooks=dict(response=get_key))


myresponse()
posted @ 2017-12-06 10:44  王亚锋  阅读(359)  评论(0编辑  收藏  举报