我计划使用https://github.com/shellycloud/forwardmachine
我想使用请求联系那些转发的服务器 我想过使用请求挂钩,但我不想在每个请求中传递它们。
我想要像这样的全球/会话:
import requests
def forwarder_pre_request_hook(req, *args, **args):
# do the trick I want, and replace the hostname and port of the url
# I would still need to figure howto do it.
return req
# globally
requests.hooks = dict(pre_request=forwarder_pre_request_hook)
# per session
requests.Session(hooks=dict(pre_request=forwarder_pre_request_hook))
有可能吗?