python error: curl: (1) Protocol "'https" not supported or disabled in libcurl

 

python 调用curl访问一个网页时,出现error: curl: (1) Protocol "'https" not supported or disabled in libcurl

控制台直接curl xxx是ok的

output = subprocess.check_output(["curl","https://stackoverflow.com/questions/6884669/curl-1-protocol-https-not-supported-or-disabled-in-libcurl"]) # error
print(output)

 这边有一个解决方案,但是对此并没有解决问题,原来是双引号的问题,换成但引号就解决问题了,一直以为但引号双引号都能表示字符串,具体为什么还不是很清楚,但是能解决问题了,需要深入再去了解下,如知请告诉我下

output = subprocess.check_output(["curl",‘https://stackoverflow.com/questions/6884669/curl-1-protocol-https-not-supported-or-disabled-in-libcurl’]) # ok
print(output)

 看demo也是单引号,curl支持但引号吗? 测试了下 pycurl都支持 但引号双引号一样

import pycurl
c = pycurl.Curl()
c.setopt(c.URL, 'https://www.taobao.com')
c.perform()

 

另外该error:

可能其他原因:

1、curl 不支持https  可以用curl -V 查看

对应解决方法是重新安装curl  可参考:http://www.codeweblog.com/curl%e4%b8%8d%e6%94%af%e6%8c%81https%e5%8d%8f%e8%ae%ae%e9%97%ae%e9%a2%98%e8%a7%a3%e5%86%b3/

wget http://archive.ubuntu.com/ubuntu/pool/main/c/curl/curl_7.35.0.orig.tar.gz
tar -xzvf curl_7.35.0.orig.tar.gz
cd curl_7.35.0.orig
./configure
make
sudo make install

 2、引号内有空格 “ https”

转载于:https://www.cnblogs.com/zhishuai/p/8094855.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值