Python请求等同于cURL的--location-trusted

时间:2015-12-18 16:03:48

标签: python curl python-requests http-authentication

使用cURL,我可以var允许向网站重定向到的所有主机发送名称+密码(http://curl.haxx.se/docs/manpage.html#--location-trusted)。

我可以在Python中使用请求库执行类似的操作吗?

2 个答案:

答案 0 :(得分:0)

psql (9.4.5) Type "help" for help. postgres=> create table x (amount int); CREATE TABLE postgres=> postgres=> insert into x values (2147483647), (2147483647); INSERT 0 2 postgres=> select sum(amount) wbtest-> from x; sum ------------ 4294967294 (1 row) postgres=> 会自动处理重定向: (http://docs.python-requests.org/en/latest/user/quickstart/#redirection-and-history
所以,这应该是一个好的开始(如果你还没有完成): (http://docs.python-requests.org/en/latest/user/authentication/

答案 1 :(得分:0)

如果必须使用libcurl(您可以合法使用!),则需要向其传递CURLOPT_UNRESTRICTED_AUTH选项。

虽然文档页面本身未提及它,但这与命令行--location-trusted标志的libcurl等效。有关更多信息,请参见the CVE page。在--location-trusted中他们介绍了var cont:Sprite = new Sprite() ; cont.name = "Container" ; addChild(cont) ; var mc1:MovieClip = new MovieClip() ; mc1.name="mc" ; cont.addChild(mc1) ; var ref1 = getChildByName("Container") ; trace(ref1.name) ; // returns "Container" trace(mc1.parent.name) ; // returns "Container" var ref = ref1.getChildByName("mc") ; ref.x = 100 ; trace(ref.x) ; // returns 100 trace(ref1.mc1.x ) ; // DOES NOT WORK trace(Container.mc.name) ; // DOES NOT WORK

相关问题