最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - How to make urllib use my own network code for the actual http GETPUT... operations? - Stack Overflow

programmeradmin1浏览0评论

I need to configure urllib in Anaconda Python 3.6 to use my own python code to do the actual GET, PUT, ... operations. The solution will be native python code and wrap the curl cli to do the acutal operation.

I'm working in a highly restrictive environment where I cannot install any software on my workstation. This limits me to Anaconda Python 3.6 with no ability to install pip modules. In this environment, I and my colleagues are using a set of python programs to collect information from internal APIs via an internal proxy. This proxy will soon be switched from basic authentication to NTLM authentication, which is not supported by Anaconda Python 3.6.

In the search for a solution, we noticed, that the 'curl' that comes with git-bash on our workstation does support NTLM authentication and can access our APIs. I made a small POC python module to wrap the curl cli tool do http requests and it worked fine. Now I'm searching for a way to use the curl tool without the need to completely rewrite all our existing code. I've already experimented with deriving classes from urllib.request.BaseHandler and urllib.request.HTTPBaseHandler, but apparently they're not meant to replace the actual networking code.

So, what would be your approach to make urllib use the curl cli command to do the actual requests? I'm aware that wrapping curl is horrible and I'm very open for alternative solutions, as long as they don't require additional software installation.

发布评论

评论列表(0)

  1. 暂无评论